Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to handle `&` symbol in search query

Given URL http://localhost:3000/?team=Video%20QA%20&%20Test%20Team&teamCode=XXXXX while decoded used URLSearchParams is represented as {"team":"Video QA "," Test Team":"","teamCode":"XXXXX"} which is wrong.
How to handle & symbol in query string to get from exampled URL this look:
{"team":"Video QA & Test Team","teamCode":"XXXXX"}

const searchParams = Object.fromEntries(new URLSearchParams(window.location.search).entries());

or tryed query-string lib, same. & symbol recognized as new object key
qs.parse('http://localhost:3000/?team=Video%20QA%20&%20Test%20Team&teamCode=XXXXX')

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

& should be encoded as %26

console.log(encodeURIComponent('Video QA & Test Team'))
Video%20QA%20%26%20Test%20Team
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading