Not redirecting top level of mount path
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
app.use(router);
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
@steve-p-com have you found a workaround for this? I'm having the same issue on my project :_(
Looks this is an issue with ExpressJS (https://github.com/strongloop/express/issues/2281)
I haven't found a workaround as I've been focussing on completing other areas of my current large project. The workaround in the first post of the linked Express issue looks promising. It may not work with query parameters on the end of the URL however.
I'm experiencing the same issue actually.