Reputation: 3006
Is there a syntax/format specified for the "search" part of the URL?
Is it alright to use like ?id!=123&(name=foo|name=bar)
?
Would this work in javascript/Spring framework or do I need to write a custom parser?
Upvotes: 0
Views: 33
Reputation: 57259
Is there a syntax/format specified for the "search" part of the URL?
Yes. The production rules for the query
part are specified in RFC 3986. I often find it is easier to look at the entire collection of production rules, which are grouped together in appendix A
query = *( pchar / "/" / "?" )
pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
pct-encoded = "%" HEXDIG HEXDIG
sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
/ "*" / "+" / "," / ";" / "="
Is it alright to use like ?id!=123&(name=foo|name=bar)?
The VERTICAL LINE is contrary to the standard; so you should percent encode it
?id!=123&(name=foo%7Cname=bar)
That should be fine.
I would be stunned if this did "just work" everywhere. We have standards for that very reason.
Upvotes: 1