I replaced PageJS routing in our application with app-location
and app-route
, and everything seems to be working except the query parameters. I noticed it can only read URLs like host?param1=val1#/view
, not host#view?param1=val1
how PageJS used to.
Upon further digging, I discovered that this is actually an RFC standard. I find it odd that PageJS and Angular can use the nonstandard query string format.
Is there a way to use the query-params
attribute of app-route
to read the nonstandard query parameters for backward compatibility?
The non-standard form works in PageJS because PageJS manually parses the query string from the URL by extracting the text that follows
?
and then parsing that for any hashes that need to be separated out. Angular might do something similar. On the other hand,<app-location>
(and<iron-location>
) uses the platform'swindow.location.search
to fetch the query parameters.If you need to stick with
<iron-location>
, you could add backward compatible support by monkey-patching<iron-location>._urlChanged()
, which is responsible for parsing the URLs for<app-location>
.Monkey-patched
<app-location>
:Alternatively, you could switch to a Polymer element that supports parsing query parameters in either form out of the box. I recommend
<nebula-location>
(which usesQS
as its query string parser).Example usage of
<nebula-location>
: