On a public web site, you cannot predict the URL a user will call to request a web page especially with tracking services like AddThis adding hash values to the links they track. The problem is the router is tricked by such unpredictable hash values and does not parse/return consistent routes for the same view whether the url includes such additions or not.
Currently the e.url property of the change event of the router is valued:
- / when calling index.html (a valid route for the SPA page)
- .UuIx1RDFKUk when calling index.html#.UuIx1RDFKUk (an invaid route for the same SPA page called with the AddThis tracking code). Note that it does not return /#.UuIx1RDFKUk which would be consistent.
I need to check, but I would not be surprised if this would also disrupt the route parsing in routes like /items(/:id), the trailing tracking code being added to the id parameter.
Many developers will be caught with unexpected bugs if the router does not parse hashes taking this into account, considering the router knows the valid routes. In other words, you need to find a way for the route parsed or returned by the router not to be disrupted with irrelevant hash values that other services may add. This is what I call "being clever".
I would also recommend considering a crawlable route scheme including an exclamation mark as explained here: https://developers.google.com/webmasters/ajax-crawling/docs/getting-started
Then parsing routes becomes simple:
- routes in the form: #!
route are kendo routes up to the following hash,
- hash values in any other forms can be discarded and considered to be irrelevant additions from third party services.
As far as your remark is concerned, the change event could return e.url (without clever parsing as currently is) and e.route
being a properly parsed, consistent and valid kendo route which can be tested with if/then statements without adding more parsing to care for unforeseen additions.
I will dig this further and get back to this thread as I will follow Google and other services guidelines to develop my project.