First of all, let me say what an elegant and useful thing express-slash is. It's already saved me lots of hassle and head scratching getting an R&D project running.
Now onto my issue. I am creating a number of different routes, and mounting them on different paths using the path parameter in app.use(). This almost works 100% as I would expect. There's is just one case where it doesn't redirect properly. It's probably easier to demonstrate than to describe, so if you take your example code and just change
to
app.use('/path', router);
These redirects work fine:
/path/about - redirects to /path/about/
/path/about/people/ - redirects to /path/about/people
The one thing that doesn't work is this:
/path
I would hope this would redirect to '/path/', but it just returns 'Home', same as requesting '/path/' would. That means relative urls referenced in an index file served from /path don't work, unless the user remembers to use the trailing slash.
Is there a workaround to make this work? I've tried appending a trailing slash to the mount path but that doesn't make any difference i.e. app.use('/path/', router) but to no avail.
Thanks
First of all, let me say what an elegant and useful thing express-slash is. It's already saved me lots of hassle and head scratching getting an R&D project running.
Now onto my issue. I am creating a number of different routes, and mounting them on different paths using the path parameter in app.use(). This almost works 100% as I would expect. There's is just one case where it doesn't redirect properly. It's probably easier to demonstrate than to describe, so if you take your example code and just change
to
These redirects work fine:
/path/about - redirects to /path/about/
/path/about/people/ - redirects to /path/about/people
The one thing that doesn't work is this:
/path
I would hope this would redirect to '/path/', but it just returns 'Home', same as requesting '/path/' would. That means relative urls referenced in an index file served from /path don't work, unless the user remembers to use the trailing slash.
Is there a workaround to make this work? I've tried appending a trailing slash to the mount path but that doesn't make any difference i.e.
app.use('/path/', router)but to no avail.Thanks