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

Trailing slash in pathname #312

Closed
cdoublev opened this issue Oct 17, 2018 · 2 comments · Fixed by #314
Closed

Trailing slash in pathname #312

cdoublev opened this issue Oct 17, 2018 · 2 comments · Fixed by #314

Comments

@cdoublev
Copy link
Contributor

A route /foo/ is currently matching an url /foo and vice-versa. I suppose that this behavior comes from path-to-regexp and that it will not be changed as FaceySpacey indicated in #63. But:

http://example.com/foo/ (with trailing slash, conventionally a directory)
http://example.com/foo (without trailing slash, conventionally a file)

Google treats each URL above separately (and equally) regardless of whether it’s a file or a directory, or it contains a trailing slash or it doesn’t contain a trailing slash.

https://webmasters.googleblog.com/2010/04/to-slash-or-not-to-slash.html

It obviously has serious SEO implications. Wouldn't be usefull to add something about that in the readme, ie. test /foo === location.pathname || redirect({ type: '/foo/' }), if it would not be handled in RFR?

@cdoublev
Copy link
Contributor Author

cdoublev commented Oct 17, 2018

It probably boils down to passing a strict option to pathToAction and use it as the second argument for calling compilePath here.

@ScriptedAlchemy
Copy link
Collaborator

Open a PR with your suggestion - if you can Mock up a small unit test for it. Ill also apply the same thing to Rudy

ScriptedAlchemy pushed a commit that referenced this issue Oct 21, 2018
* feat(connectRoutes): add strict option for trailing delimiter

/foo route's path is matching /foo and /foo/ urls by default. Setting strict option to true makes
/foo match /foo url but not /foo/.

fix #312

* feat(connectRoutes): add doc for strict option
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

Successfully merging a pull request may close this issue.

2 participants