Query string (source code)

= Query string

A <query string> is the component following `?` and preceding `#`, or the end, in a <URL>. It carries data whose interpretation is defined by the resource or application. The generic syntax does not require a dictionary of names and values.<Uniform Resource Identifier (URI): Generic Syntax>[Section3.4: query component]{ref}

For example, `https://example.org/search?q=red&tag=a&tag=b#results` has query `q=red&tag=a&tag=b`. An application using form-style conventions can interpret repeated `tag` entries as a list. <URLSearchParams> preserves repeated entries: `getAll('tag')` returns both `a` and `b`. Converting that list directly into a dictionary with one value per name can lose information.

Encoding conventions also matter. Under <URLSearchParams> parsing, `q=a+b` gives the value `a b`, while `q=a%2Bb` gives `a+b`. That distinction comes from the specified form parser, rather than a general law that every plus in every <URL> means a space.<URL Standard by WHATWG>[Section5.1; Section6.2: repeated tuples and getAll]{ref}

A useful test records both the original <query string> and the parsing convention. A changed spelling, changed list of values and changed server response are three different observations.