Within the query string, the plus sign is reserved as shorthand notation for a space. Therefore, real plus signs must be encoded. This method was used to make query URIs easier to pass in systems which did not allow spaces.
This plus sign is also not required by the JSONAPI spec, which says:
The sort order for each sort field MUST be ascending unless it is prefixed with a minus (U+002D HYPHEN-MINUS, "-"), in which case it MUST be descending.
As-is, this implementation of ascending sort is not compatible with popular server-side frameworks like Rails' jsonapi-resources, which returns a 400: Bad Request since it interprets the + sign as a leading space, not as a plus.
It also doesn't match the JSONAPI spec.
Routing.swift line 156 builds an ascending sort order with a prepended
+
:However, this gets converted into a path that looks like
/api/cameras/21/sleeps?sort=+started-at
, which without extra encoding is interpreted as a space character per https://www.w3.org/Addressing/URL/4_URI_Recommentations.html:This plus sign is also not required by the JSONAPI spec, which says:
(http://jsonapi.org/format/#fetching-sorting)
As-is, this implementation of ascending sort is not compatible with popular server-side frameworks like Rails'
jsonapi-resources
, which returns a400: Bad Request
since it interprets the+
sign as a leading space, not as a plus.