zhang-arvin opened a new pull request, #7013:
URL: https://github.com/apache/shenyu/pull/7013
Fixes #6883.
## Bug Description
The RewritePlugin has two bugs in its placeholder branch:
1. **First character of path-variable value is dropped**:
`rewriteUri.substring(rewriteHandle.getRegex().indexOf("{") + 1)` skips the
first character of the actual path-variable value because the `+1` is meant to
skip the `{` character in the regex pattern, but it's applied to the rewriteUri
which has the actual value at that position.
2. **StringIndexOutOfBoundsException when regex lacks `{`**: The condition
only checks `rewriteHandle.getReplace().contains("{")` but not
`rewriteHandle.getRegex().contains("{")`. When the replace pattern contains `{`
but the regex doesn't, `indexOf("{")` returns -1, causing `substring(-1)` to
throw.
## Fix
- Added `rewriteHandle.getRegex().contains("{")` to the guard condition
- Removed the `+1` offset from `rewriteUri.substring()` to preserve the
first character
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]