-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Optional trailing slash #2656
Comments
Pinging @braddunbar, in particular about these two lines:
... did you have a definite opinion at the time the change was made about root URLs (without additional components) needing to include the trailing slash? Or was that just a side effect of assuming that roots will usually only be a prefix for additional URL components? |
Definitely the latter. I don't have a strong opinion on trailing slashes on the root, though I'm not aware of any problems with it. @joshpangell What problem is the trailing slash causing? Is it purely aesthetic or does it cause a technical issue? |
Then let's assume that "pure" root URLs never have a trailing slash put on by us ... although perhaps we allow you to |
Sounds good, patch incoming. |
@braddunbar The trailing slash is not causing a technical issue per say, but aesthetics are very important :) |
I addressed this in #2659, but I'm not sure I like the solution. For one, I'm uncomfortable fiddling with such a finicky portion of the code for something that's not currently causing any problems. And for two, there are some caveats, as described in the pull. These could possibly be addressed, but it seems like a lot of trouble for a trailing slash. |
A potential caveat is cache. Many people cache based on URL, especially with Varnish. Slashes in the URL are looked at as different locations, when in fact they are not. |
Right-o. Instead of this fiddling, can we simply normalize to never include the slash directly on the root? |
Sure thing, updated in 151bd73. |
Fix #2656 - Trailing slash on root.
I'm developing a WordPress theme based on Backbone and using pretty permalinks as http://example.com/multi-site-name/yyyy/mm/dd/post-name/. Assuming the root route is /multi-site-name/, automatically remove trailing slash is a problem in this case 'cause home page url becomes http://example.com/multi-site-name instead of http://example.com/multi-site-name/ and if I refresh my web browser when I am on http://example.com/multi-site-name, I have a loading extra time 'cause WordPress redirects to http://example.com/multi-site-name/ |
Same as @Deknar here. |
I know this is kind of old, but since I found this in a search I figured I'd post my solution as I haven't found any updates otherwise to allow us to specify optionally how we want it handled. The removal of the slash was causing my identity solution to issue relogin requests every time I hit the home route without the trailing slash. Notes: -I used the minified version for the most part and changed History.started to Backbone.History.started and the call for pathStripper needed to reference Backbone.pathStripper since this is being called outside the class. Just place this somewhere in your JS after the dom is ready.
|
When defining a root route, then pushing history onto the stack, then removing it, there is a trailing slash left over. This is not very desirable and would be great as an optional flag when starting history.
The origin of this appears to reside in the code here.
As an example:
Opening a page and pushing it onto the history stack works.
Result: example.com/myroot/Page-name (this is the desired result)
Then, when closing the page, passing a blank value to remove the page url creates a trailing slash:
Result: example.com/myroot/
Desired result: example.com/myroot (no trailing slash)
The text was updated successfully, but these errors were encountered: