Skip to content

Not redirecting top level of mount path #7

@ghost

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions