Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

redirect won't go to / but empty quotes works #291

Closed
arxpoetica opened this issue Jun 23, 2018 · 5 comments
Closed

redirect won't go to / but empty quotes works #291

arxpoetica opened this issue Jun 23, 2018 · 5 comments

Comments

@arxpoetica
Copy link
Member

(In preload) like so:

return this.redirect(302, '/') // it be broke
return this.redirect(302, '') // it work
@arxpoetica
Copy link
Member Author

Probably another way to say this, leading slashes don't work.

@Rich-Harris
Copy link
Member

How do you think this ought to be handled? Should Sapper just strip any leading / character?

@arxpoetica
Copy link
Member Author

arxpoetica commented Jun 26, 2018

Good Q. Maybe follow Express conventions? From https://expressjs.com/en/guide/routing.html:

Express uses path-to-regexp for matching the route paths; see the path-to-regexp documentation for all the possibilities in defining route paths.

It appears the leading / is optional: /^\/?$/i

Update Q: is routing a separate issue though?

@s3ththompson
Copy link
Contributor

This threw me today. I expected the routes to be relative if they didn't have a starting /...

@Rich-Harris
Copy link
Member

released 0.15.7 with the fix

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants