Skip to content
Discussion options

You must be logged in to vote

@jamesmacwhite redirecting to a trimmed trailing slash is exactly the same, but without a trailing slash:

  - pattern:
      pathname: '/:noSlashes+'
    destination: '/{matches.pathname.groups.noSlashes}'
    status: 301

Because of how URLPattern's pathname matching works, the pathname: '/:noSlashes+' will match /all/the/segments/but/no/trailing/slash, so we just need to reference the match and include the trailing slash or not.

Proably a good idea to include both examples in our docs, though. /cc @AugustMiller

Replies: 1 comment 9 replies

Comment options

You must be logged in to vote
9 replies
@jamesmacwhite
Comment options

@timkelty
Comment options

@jamesmacwhite
Comment options

@timkelty
Comment options

@jamesmacwhite
Comment options

Answer selected by jamesmacwhite
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants