Open roger-on-github opened 3 years ago
Hi Roger,
It's specified in the URL spec, here.
That format isn't actually fixed across all URLs -- or even all HTTP URLs. It was originally defined by HTTP and then migrated into the URL spec later. Furthermore, the URL specification doesn't (yet) specify syntax; only parsing algorithms. For the syntax, RFC3986 is authoritative (although there are some small differences between the two specs).
application/x-www-form-urlencoded specifies something, but nowhere is it matched with a defined term of a "query parameter" - so it's not helpful from a normative reference standpoint.
RFC3986 likewise defines the query component, and even makes passing reference to key=value pairs, but likewise does not define a "query parameter" or the rules for composing or parsing one.
Yes - because the query string of an URL can be in any format that conforms to the 3986 syntax - this is just one -- albeit extremely common -- option.
Agreed. And it is my point that it would be helpful if something codified this extremely common option for the purposes of common reference.
Specifically, are you arguing that there should be a formal grammar, as well as a parsing algorithm?
I don't know what would fit best within the whatwg URL spec, but yes, I'm suggesting that somewhere there be language along the lines of "A URL-query-string MAY be composed of a set of URL-query-parameters separated by &, A URL-query-parameter has the following syntax, etc."
It seems somewhat reasonable to link from https://url.spec.whatwg.org/#concept-url-query to https://url.spec.whatwg.org/#concept-urlencoded-string-parser in a note or so. I'm not sure we'd want to say anything normative though.
Sounds like a duplicate of #491?
I also wondered how the official term "query string" lead to URLSearchParams
…
It's not a duplicate, see the comment right before yours. (As for terminology, "search" has been the API term for "query" on the web since forever.)
There are many, many APIs and network protocols that require the use of URL query parameters (
http://example.com/resource?a=b&c=d
). But I have not been able to find an authoritative definition of the term in any spec. Most URL specs go as far as defining the query part of the URL and its allowed character set, but stop short of defining its use as a list of key+value pairs.It would be enormously helpful if a definition for query parameters could be added to the whatwg URL spec.