-
Notifications
You must be signed in to change notification settings - Fork 540
Description
I opened an equivalent issue on the JSON API spec project: json-api/json-api#486
If I am not mistaken, many web servers see the plus symbol ("+") as a substitute for a white space or "%20" when sent as a query param in the URL. For example, this request
GET /people?sort=+age,+name
shows up as " age, name" to the Request.parse_sort_criteria method. Which is a total bummer for the if statement
if sort.start_with?('+')
sort_criteria[:direction] = :asc
elsif sort.start_with?('-')
sort_criteria[:direction] = :desc
else
@errors.concat(...)
endThe spec compliant GET request leads to a 400 error because " age" and " name" both start with a white space instead of a "+"!
I find I can address this by either allowing a leading white space to behave as a + (e.g. sort.start_with?(' ')) or using %2b to represent + in the query params and using something like sort_criteria = URI.unescape(sort_criteria) to decode %2b into +.
Is there a preference for using one, the other, or both?