Skip to content
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

All routes/urls should have a trailing slash. Missing trailing slashes should be added #448

Closed
4 tasks
ErisDS opened this issue Aug 19, 2013 · 2 comments
Closed
4 tasks
Assignees
Milestone

Comments

@ErisDS
Copy link
Member

ErisDS commented Aug 19, 2013

Every route in Ghost should expect a trailing slash.

  • If a request is made to Ghost which does not have a trailing slash, assume it is incorrect, and add the trailing slash before attempting to match the route (middleware?)
  • Add trailing slash to permalinks
  • Ensure settings subpages have a trailing slash
  • All other routes which don't have a trailing slash should have one added, including the API
@ErisDS
Copy link
Member Author

ErisDS commented Sep 4, 2013

Was lookng for the best way to do this. Middleware, regex, something else?

Found this interesting read: https://groups.google.com/forum/#!topic/express-js/-irYaQqRZ3M

A summary of the interesting points:

A URL ending in a slash is a directory, and a URL without a slash is a
resource. So /users/ would be a list of users, and /users/bob would be
a single user.

Therefore the suggested solution is to do this:

/users -> 301 redirect to /users/
/users/ -> 200
/users/bob -> 200
/users/bob/ -> 301 redirect to /users/bob

And there is middleware available to do it: https://github.com/avinoamr/connect-slashes

@JohnONolan
Copy link
Member

I would prefer to have a trailing slash on everything and just keep it consistent - what the trailing slash actually means is largely conjecture/speculation. Feels like the old days of arguing .php/.asp vs .htm

@ghost ghost assigned cobbspur Sep 9, 2013
cobbspur added a commit to cobbspur/Ghost that referenced this issue Sep 15, 2013
ref issue TryGhost#448

- adds slashes to urls, templates and tests

TODO

Add function to add slash to urls automatically
ErisDS pushed a commit that referenced this issue Sep 17, 2013
ref issue #448

- adds slashes to urls, templates and tests

TODO

Add function to add slash to urls automatically
ErisDS added a commit that referenced this issue Sep 17, 2013
@ErisDS ErisDS closed this as completed Sep 17, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants