Skip to content

FIELD NOTES / A DECISION GUIDE

Encode a search filter without splitting the query

Suppose a catalog filter needs to search for the literal label “Tea & Cakes” and sort by price. The ampersand in the label belongs to one value. The ampersand before the sort parameter separates two parameters.

Encode just the value

In the URL codec, select Encode and One value. Paste Tea & Cakes. The expected percent-encoded result is Tea%20%26%20Cakes. Use it to build this synthetic query:

?q=Tea%20%26%20Cakes&sort=price

Check the round trip

Take the encoded value after q= and before &sort, then decode it as one value. The decoded ampersand is part of the label. If your application receives a third parameter after parsing the complete query, check whether the label was inserted before encoding.

When an application builds query strings for you, pass it the raw label and let it encode once. A second encoding pass changes a percent escape such as %26 to %2526.

Open the URL codec or browse all three tool guides.