I'm not sure if it serves you well, but i have a library that handles query params very well specially for browsers path. perhaps it is handy in your case too, lemme know if you need any specific changes.