Skip to content

Conversation

AlinsRan
Copy link
Contributor

@AlinsRan AlinsRan commented Oct 11, 2025

Type of change:

  • Bugfix
  • New feature provided
  • Improve performance
  • Backport patches
  • Documentation
  • Refactor
  • Chore
  • CI/CD or Tests

What this PR does / why we need it:

fix two issues:

  1. Prefix-only paths do not match
    Requests like /prefix do not match the pattern because it requires a trailing /.

  2. Extra or missing slashes
    The replacement template unconditionally appends /$2, causing incorrect results when $2 is empty or when replaceTarget is /.

  rules:
  - matches:
    - path:
        type: PathPrefix
        value: /prefix/one
    filters:
    - type: URLRewrite
      urlRewrite:
        path:
          type: ReplacePrefixMatch
          replacePrefixMatch: /one
  - matches:
    - path:
        type: PathPrefix
        value: /strip-prefix
    filters:
    - type: URLRewrite
      urlRewrite:
        path:
          type: ReplacePrefixMatch
          replacePrefixMatch: /
request path expect actual
/strip-prefix / unmatched
/prefix/one/two /onet/wo /onetwo
Request path | Expected path | Actual path -- | -- | -- /strip-prefix | / | unmatched /prefix/one/two | /one/two | /onetwo

Pre-submission checklist:

  • Did you explain what problem does this PR solve? Or what new features have been added?
  • Have you added corresponding test cases?
  • Have you modified the corresponding document?
  • Is this PR backward compatible? If it is not backward compatible, please discuss on the mailing list first

@AlinsRan AlinsRan marked this pull request as ready for review October 11, 2025 05:13
Copy link
Contributor

@ronething ronething left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@AlinsRan AlinsRan merged commit 1513202 into apache:master Oct 13, 2025
23 checks passed
@AlinsRan AlinsRan deleted the fix/urlRewritePath branch October 13, 2025 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants