This is an automated email from the ASF dual-hosted git repository.
xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new c6c7fdbb62 [type:fix] fix context path error (#5393)
c6c7fdbb62 is described below
commit c6c7fdbb629ed9b6d633c6a72bbf95e1d950a6a3
Author: moremind <[email protected]>
AuthorDate: Wed Jan 3 14:02:03 2024 +0800
[type:fix] fix context path error (#5393)
---
.../shenyu/plugin/context/path/ContextPathPlugin.java | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git
a/shenyu-plugin/shenyu-plugin-context-path/src/main/java/org/apache/shenyu/plugin/context/path/ContextPathPlugin.java
b/shenyu-plugin/shenyu-plugin-context-path/src/main/java/org/apache/shenyu/plugin/context/path/ContextPathPlugin.java
index d2ab962a45..2d2d888be4 100644
---
a/shenyu-plugin/shenyu-plugin-context-path/src/main/java/org/apache/shenyu/plugin/context/path/ContextPathPlugin.java
+++
b/shenyu-plugin/shenyu-plugin-context-path/src/main/java/org/apache/shenyu/plugin/context/path/ContextPathPlugin.java
@@ -87,14 +87,19 @@ public class ContextPathPlugin extends AbstractShenyuPlugin
{
* @param handle handle
*/
private void buildRealURI(final ShenyuContext context, final
ContextMappingRuleHandle handle) {
+ String realURI = "";
String contextPath = handle.getContextPath();
if (StringUtils.isNoneBlank(contextPath)) {
-
context.setRealUrl(context.getPath().substring(contextPath.length()));
- } else {
- String addPrefix = handle.getAddPrefix();
- if (StringUtils.isNoneBlank(addPrefix)) {
- context.setRealUrl(addPrefix + context.getPath());
+ realURI = context.getPath().substring(contextPath.length());
+ }
+ String addPrefix = handle.getAddPrefix();
+ if (StringUtils.isNoneBlank(addPrefix)) {
+ if (StringUtils.isNotBlank(realURI)) {
+ realURI = addPrefix + realURI;
+ } else {
+ realURI = addPrefix + context.getPath();
}
}
+ context.setRealUrl(realURI);
}
}