I know that there are some issues with having duplicate content (SEO), but that is not something that my project is concerned with.
In my backbone router, I have this :
routes: {
"": "startOrder",
"order/:orderNumber/:stepName": "getOrder",
"order/:orderNumber/:stepName/": "getOrder"
},
Notice that the second and third routes lead to the same thing.
The problem is if someone enters a URL ending with simply the "/" character, I would like it to call a separate function (and then remove the slash), but this doesn't happen, it always matches to the blank route. Then I get issues later on because the URL has a slash where it shouldn't.
Am I missing something?
It is now possible to put a slash within parenthesis as an optional part of the route:
var Router = Backbone.Router.extend({
routes: {
'order/:orderNumber/:stepName(/)': 'getOrder'
},
// ...
});
From a pretty comprehensive issue thread on the topic of slashes at the end of Backbone routes.
But as also noted in that thread, to prevent multiple URLs being recorded for your pages it's best to remove the slash at the end of paths in Apache or other server configuration.