-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
removes trailing / #1
Conversation
Hey @cj, Trailing slashes are going to keep me up at night! :P This must be one of the most debated areas of routing and URI schemes. I really want the simplest API possible and stripping the trailing slash seems to do that. At the same time I'm not sure that covers all the bases when it comes to identifying resources. http://googlewebmastercentral.blogspot.com/2010/04/to-slash-or-not-to-slash.html These are the 2 big topics.
I'm not sure if either of these should have any affect on a client-side router. I went through some of the existing routers to see what they do. Angular ui-router does not ignore trailing slashes but you can add a rule to ignore them. Backbone treats all variations of leading and trailing slashes differently. flatiron-director doesn't even allow trailing slashes in it's routes by default. They have a configuration I had to deal with trailing slashes to get the gh-pages working. The <app-route path="/app-router/" import="pages/home-page.html"></app-route> Other routes that use hash paths <app-route path="/api" import="pages/api-page.html"></app-route> I ignored the issue in my first implementation and treated trailing slashes as separate paths. This is what Backbone and the Angular ui-router do. It's the simplest approach in the code but forces the complexity onto the end user. I don't really like it. I think these are some options.
Redirects get really tricky when the user isn't using hash paths I'm not sure what to do here. I'm not ready to start stripping all trailing slashes. I don't want to close this issue since I want a good solution for this. I'll need some more time for reading. Comments are all good too! In the mean time, you might be able to get away with adding a trailing slash to every app-route. |
I went ahead with a variation on this. https://github.com/erikringsmuth/app-router#app-router-options My thinking is that this could end up being configured in multiple other ways. The first two will be strict (default) and ignore. After some more reading I found out the Angular ui-router will redirect a route to the matching route. For example a route
Thanks for the PR! It got me thinking all day! |
@erikringsmuth Awesome, I like where you went with this. Thanks again for this lib :) |
some rewriters add a trailing slash on missing urls, this makes sure they will work.
p.s. thank you for this amazing lib!