Closed paoloricciuti closed 1 year ago
Is this supposed to remove the parameter if the value of the parameter is null/undefined?
Is this supposed to remove the parameter if the value of the parameter is null/undefined?
It should but it also depends on other parts of the code...is this not happening?
(personal account)
In my case it is not. I'll see if I can make a minimal repro.
Here is a reproduction:
Navigate to /params-issue
The error occurs when trying to update param values with null/undefined. Get this stacktrace (not sure if related yet).
Some context: In the application I'm building, there is a search box + certain pages have their own search boxes. I want to remove params created by the opposing search if a user uses the other kind of search.
I will have a look if I can create a fix, but I'm not sure whether it's just my usage is off, or if there is an issue with queryParams not getting removed from URL when they should be.
Thanks!
I'm not sure what the intention of this line is tbh, but if I remove the ! and an undefined param/val is encountered, then it's removed how i would expect it to be removed.
I'm not sure what the intention of this line is tbh, but if I remove the ! and an undefined param/val is encountered, then it's removed how i would expect it to be removed.
Yup looks like a bug...it was previously !value[field]
and I added == undefined
and probably forgot to remove the !
Thanks for reporting and also find the solution. If you want to make a PR to be credited as a contributor feel free to do it otherwise I'll go ahead and fix it in a while
Cool, i'll make a PR tonight :)
https://github.com/paoloricciuti/sveltekit-search-params/blob/2393a23fb54a187fdf7168823e58a4a26a696753/src/lib/sveltekit-search-params.ts#L105