Sapper: redirect won't go to `/` but empty quotes works

Created on 23 Jun 2018  路  5Comments  路  Source: sveltejs/sapper

(In preload) like so:

return this.redirect(302, '/') // it be broke
return this.redirect(302, '') // it work

Most helpful comment

released 0.15.7 with the fix

All 5 comments

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

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

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?

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

released 0.15.7 with the fix

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Rich-Harris picture Rich-Harris  路  3Comments

milosdjakovic picture milosdjakovic  路  3Comments

Snugug picture Snugug  路  4Comments

mylastore picture mylastore  路  3Comments

antony picture antony  路  3Comments