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 breaks url #323

Closed
mrkvon opened this issue Dec 15, 2015 · 4 comments
Closed

Trailing slash breaks url #323

mrkvon opened this issue Dec 15, 2015 · 4 comments
Milestone

Comments

@mrkvon
Copy link
Contributor

mrkvon commented Dec 15, 2015

https://trustroots.org/profile/:someusername is ok, but
https://trustroots.org/profile/:someusername/ leads to 404 not exist.
the same with /search vs. /search/ and other urls.
Maybe it's by design, but it is confusing, i.e. when one writes a link from one's (human) memory and adds the slash accidentally (happened already).
I'm not sure about best practices/standards for this, but enabling it or (permanent?) redirect would be cool.

fast research:
possible fix: http://stackoverflow.com/questions/13442377/redirect-all-trailing-slashes-gloablly-in-express
some fun with redirecting and trailing slashes: http://expressjs.com/en/api.html#res.redirect
and some article etc.

@simison
Copy link
Contributor

simison commented Dec 15, 2015

Thanks. Totally should work.

Since URL stuff is mostly happening at client side (not at Express), I don't think we can easily create 301 redirects for these.

We're using Angular ui-router.

Here's the config for users module (every module has its own config file):

https://github.com/Trustroots/trustroots/blob/master/modules/users/client/config/users.client.routes.js#L41

And here seems to be the solution: angular-ui/ui-router#50 (towards the end of the thread)

@simison simison added this to the soonish milestone Dec 15, 2015
@mrkvon
Copy link
Contributor Author

mrkvon commented Dec 19, 2015

That last link with solution has reference to this: https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-make-a-trailing-slash-optional-for-all-routes

Set strictMode to false in your config block:

$urlMatcherFactoryProvider.strictMode(false)

Don't have any experience with MEAN or Angular. I wonder whether there is any place where angular.js can be configured globally (maybe here?) to something like this:

angular.config(function ($urlMatcherFactoryProvider) {
    $urlMatcherFactoryProvider.strictMode(false);
});

Otherwise it would have to be configured in the individual modules (which is not very DRY).
Didn't manage to install trustroots locally today. Otherwise would test it.

@simison
Copy link
Contributor

simison commented Dec 19, 2015

Cool. I'll test that out at some point. That would go here https://github.com/Trustroots/trustroots/blob/master/modules/core/client/app/init.js#L15

@simison simison reopened this Mar 3, 2016
simison added a commit that referenced this issue Mar 9, 2016
@simison
Copy link
Contributor

simison commented Mar 9, 2016

Finally works, e.g.: https://www.trustroots.org/statistics/

@simison simison closed this as completed Mar 9, 2016
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

2 participants