Skip to content

useSearchParams not parsing URL params containing escaped ampersands (&) #66989

Answered by icyJoseph
Haldaug asked this question in App Router
Discussion options

You must be logged in to vote

Well, yes that's my stance. I can "prove" it like this:

Say you have:

<route>
  <from uri="example:start?foo=1&amp;bar=2"/>
  <to uri="example:result"/>
</route>

Then I can do:

const xml = `<route>
  <from uri="example:start?foo=1&amp;bar=2"/>
  <to uri="example:result"/>
</route>`

const parser = new DOMParser();

const result = parser.parseFromString(xml, 'text/xml');

console.log(result.getElementsByTagName("route")[0].children[0].attributes.uri)

And that'll give me back the proper query params. So, anyone who parses your XML, properly, will get the correct query params into their data structure, and be able to make the right calls

And that'd log

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@Haldaug
Comment options

@icyJoseph
Comment options

@Haldaug
Comment options

@icyJoseph
Comment options

Answer selected by Haldaug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants