juicewcode opened a new pull request, #6951:
URL: https://github.com/apache/shenyu/pull/6951
Fixes #6882
## Changes
- Remove the `+1` in `rewriteUri.substring(regex.indexOf("{"))`, so the
full
path-variable value is extracted instead of skipping its first character
—
avoids the silent truncated upstream path (`/123` → `/23`).
- Guard the placeholder-substitution branch with
`rewriteHandle.getRegex().contains("{")`
so it is only entered when both the replace template and the regex
contain `{`;
otherwise fall back to the plain `replaceAll` branch — avoids the
`StringIndexOutOfBoundsException` / 500 on every matching request.
## Tests
- `shouldRewritePathVariableWithCompleteValue` — verifies the path-variable
value is rewritten completely (`/shenyu/123`), not truncated.
- `shouldNotThrowWhenOnlyReplaceContainsPlaceholder` — verifies no
exception is
thrown when the replace template has `{` but the regex does not.
<!-- Describe your PR here; e.g. Fixes #issueNo -->
<!--
Thank you for proposing a pull request. This template will guide you through
the essential steps necessary for a pull request.
-->
Make sure that:
- [x] You have read the [contribution
guidelines](https://shenyu.apache.org/community/contributor-guide).
- [x] You submit test cases (unit or integration tests) that back your
changes.
- [x] Your local test passed `./mvnw clean install
-Dmaven.javadoc.skip=true`.
--
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]