You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The toggle was never made to work with arrays. Basically, it looks to the URL and if the value is equal to what you send, it removes it. If the value is not equal to what you send, it adds it.
Aa a workaround, you could use set, but I understand that it is not as convenient.
Introducing such functionality would be a breaking change and I'm not sure it would be straightforward enough, beacuse we would be treating two values with different behaviour.
I think that when it is possible to add values as an array a remove method for 1 value should also exist. I see a discussion at whatwg going on on the same topic. whatwg/url#335
But until that time URLsearchparams will incorporate this i think it would be a usefull addition to Qsm.
instead of Qsm.delete(),as suggested in the Whatwg discussion, i would opt for a Qsm.remove() method so not to confuse the standard delete functionality from URLsearchParams.
So Qsm.remove({"key":"value"}),
just my thoughts
RDG
I cant get the toggle function to work.
first i set a few params with:
then i try to remove one of the with:
qsm('https://www.google.cz/search?q=hello+world&num=20', {
toggle: {
num: 40,
}
});
then the all other params 'num' are gone.
Can it be that the function
toggleParams
is not returning anything? looks like it should returnurlParamsNext
Im using the NPM version
RDG
The text was updated successfully, but these errors were encountered: