Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>> I cannot encode the ampersands before the string is made due to the nature of this project</p> <p>Then you won't have a full-proof answer.</p> <p><a href="http://en.wikipedia.org/wiki/Query%5Fstring#URL_encoding" rel="nofollow noreferrer">Ampersands (<code>"&amp;"</code>) separate query parameters in url query strings</a>. You can't have it both ways where some of your query parameter values contain un-escaped <code>"&amp;"</code> and expect a parser based on this simple rule to know the difference.</p> <p>If you can't escape <code>"&amp;"</code> as <code>"%26"</code> in each value component beforehand, then you can never <em>know</em> that the values you get are correct. The best you could do is: If the value to the right of an <code>"&amp;"</code> and before the next <code>"&amp;"</code> does <em>not</em> contain an equal sign <code>"="</code>, you append the value to the previous value read, or the empty string if this is the first value read.</p> <p>This requires a proper parser as JavaScript does not support lookahead regular expressions that could help you do this.</p> <p>Note however that an algorithm like that completely bypasses the spec. Presuming for a moment that the query string: </p> <pre><code>a=test&amp;b=cats &amp; dogs&amp;c=test </code></pre> <p>is valid, technically that string contains <strong>4</strong> parameters: <code>"a"</code> (with a value of <code>"test"</code>), <code>"b"</code> (with a value of <code>"cats "</code>), <code>" dogs"</code> (with no value), and <code>"c"</code> (with a value of <code>"test"</code>).</p> <p>If you don't change the query string at the source (and properly escape the value component), you're just hacking in the wrong solution.</p> <p>Good luck.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload