: Usage of comma in URL: encoded or not encoded Even have seen a page, where in the same url were both of enocoded and not encoded commas, like: https://example.com/product?filter_color:blue,green&filter_size:xl%2Cxxl
Even have seen a page, where in the same url were both of enocoded and not encoded commas, like: example.com/product?filter_color:blue,green&filter_size:xl%2Cxxl
My knowledge about the subject is a bit messy:
On the one side, in a URI RFC i've read, comma would be a socalled reserved character and should be in URLs always encoded.
On the other side i've seen many websites, where comma wasn't encoded.
The question arose because of usage of both encoded and non encoded variant: how should it be done correctly: encode or non encode?
More posts by @Looi9037786
1 Comments
Sorted by latest first Latest Oldest Best
, is a reserved character. Reserved characters are never equivalent (for normalization purposes) to their percent-encoded variants. So these URIs are not equivalent:
example.com/?foo,bar
example.com/?foo%2Cbar
Neither the URI standard¹ nor the HTTP/HTTPS URI scheme specs define a special role for , in the query component. This means that authors may use , to represent data in the query component (i.e., for whatever they want).
It can make sense to use , together with %2C in an URI’s query component. For example, an author could decide to use , for separating name-value pairs, and %2C for representing commas within values:
example.com/?score:1%2C4,time:55
(It doesn’t seem to make sense in the example URI in your question, though. Assuming that the values are "blue" and "green", as well as "xl" and "xxl", it would make more sense to either use , or %2C in both cases. Your example URI would make sense if e.g. the latter case is actually one value, so "xl,xxl".)
¹ Note that RFC 2396 is obsolete. IETF’s URI standard should always be accessible under STD 66, which is currently RFC 3986.
I gave a similar answer to the question Possible side effect using comma in querystring? on Stack Overflow.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.