First, some background: I work on a project that has an established request API pattern. One of the patterns is to use the same param name for OR and range filters in the query params. For example:
A date range of 2015-02-01
to 2015-02-15
is to be constructed as:
-http://my-project.dev?dateRange=2015-02-01&dateRange=2015-02-15
Similarly, looking for statuses of active and deleted is expected to be:
-http://my-project.dev?status=active&status=deleted
Under normal circumstances, this is just a simple request to REST API and I can construct the request anyway the API expects. But the tricky thing is, this URL is also expected to populate the browser location bar. And when this happens, Ember collapses the repetitive param names into a single param of the said name and takes the last value even if the location bar shows them repeated. And the problem is compounded as the user starts to sort the table…
The end result is:
-http://my-project.dev?status=deleted&sortProperties=…< snip >
So my question is: How does one go about keeping the states of request params of the same name? Do I have to override the serializeQueryParam
and deserializeQueryParam
methods in the route somehow?
Thanks for your time.
Correction: Previously I’d mis-stated that the “browser” collapses the query param keys. It’s actually Ember that performed the collapsing as it deserializes the query params into a JSON object and uses it to build a query string with.