query-string icon indicating copy to clipboard operation
query-string copied to clipboard

Keep the + sign in the URL

Open ariel-upstream opened this issue 2 years ago • 1 comments

I saw the issue: https://github.com/sindresorhus/query-string/issues/305 And I understand the concept but is it possible to add a flag to the queryString.parse options that will keep the + sign and will not replace them with a space? something like:

const paramsUrl = queryString.parse(decodeURIComponent(location.search), {
      parseBooleans: true,
      ignorePlus: true
      arrayFormatSeparator: "|",
      arrayFormat: "bracket-separator",
    })

ariel-upstream avatar Sep 28 '23 12:09 ariel-upstream

What's the word on this?

joeyfigaro avatar Jul 17 '24 19:07 joeyfigaro

I don't plan to add an option for this. By standard (application/x-www-form-urlencoded) and by URLSearchParams, + in the query is a space; libraries should match the platform, not invent a new dialect. If you need a literal plus, encode it as %2B (use stringify() or URLSearchParams.append). If you’re parsing untrusted, non-conformant input and must preserve raw +, use parse(..., {decode:false}) and do selective decoding yourself. Also: don’t pre-decode, pass location.search directly to parse().

sindresorhus avatar Sep 18 '25 09:09 sindresorhus