D
D
Denis Bukreev2016-11-14 10:22:49
JavaScript
Denis Bukreev, 2016-11-14 10:22:49

History.API puts / when adding GET variables to the address - how to avoid it?

I use the jquery.history.js plugin
On the page with the address http://larouge/dressing, when clicking on certain headings, I add a GET variable to the address (for further sharing if the user shares the link).
But instead ?playlist=discoof adding /?playlist=disco.
How to avoid adding a slash?
Here is the code:

History.pushState(null, document.title, `?playlist=${scName}`);

scName contains the name of the playlist.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Risent Veber, 2016-11-14
@denisbookreev

For the standard browser API without any JQuery there, this way will do
For this plugin, try

History.pushState(null, document.title, `${window.location}?playlist=${scName}`);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question