-
Notifications
You must be signed in to change notification settings - Fork 65
Description
Per section 12.1.2 of the JSON:API spec, "Square Brackets in Parameter Names",
With query parameter families, JSON:API allows for query parameters whose names contain square brackets (i.e., U+005B “[” and U+005D “]”).
According to the query parameter serialization rules above, a compliant implementation will percent-encode these square brackets. However, some URI producers — namely browsers — do not always encode them.
It looks like in the JSONAPI::Pagination
module, not encoding them is a deliberate choice:
links[page_name] = original_url + CGI.unescape(
original_params.to_query
)
I'm honestly on the fence about this; I mean yes, there's an argument that hypermedia URLs should be opaque, but boy howdy it makes debugging a lot easier when they're not. And the WHATWG URL spec seems to allow square brackets in query strings, even if RFC 3986 doesn't. On the other hand, most Ruby / Rails code follows RFC 3986 (where it's not still on RFC 2396), and also the WHATWG has a reputation for not caring much about APIs.
So this isn't a bug report per se, more a question about what the design intent is here -- I'm trying to implement filters and I'm finding it surprisingly annoying (at least in Ruby / Rails) to generate these URLs with the square brackets intact, so while I'd prefer to be consistent, I'm wondering why / whether it's worth it (and maybe what jsonapi.rb
knows that I don't).