Skip to content

strip doesn't work as expected on redirect #824

@far-blue

Description

@far-blue

I'm trying to use strip and redirect together and I'm not getting the behaviour I'd expect.

What I'm trying to do is:

urlprefix-<host>/news strip=/news redirect=301,https://<host>/bulletin/$path

However, the strip isn't working.

Looking at the code here:

if t.StripPath != "" && strings.HasPrefix(t.RedirectURL.Path, t.StripPath) {

It looks like the redirect destination is assembled first, and then the strip prefix is checked. In my case this would first convert /new/foo into /bulletin/news/foo, then attempt to apply the strip - which will fail.

I suspect the code should actually be applying the prefix check and strip to the replaceRawPath var rather than the t.RedirectURL.Path var.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions