Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-cloud-netflix
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
spring-cloud-netflix
Commits
d2155dc5
Unverified
Commit
d2155dc5
authored
Jan 08, 2018
by
Ryan Baxter
Committed by
GitHub
Jan 08, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only strip the prefix if it actually part of the path. Fixes #2377 (#2624)
parent
882219f9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletion
+12
-1
SimpleRouteLocator.java
...mework/cloud/netflix/zuul/filters/SimpleRouteLocator.java
+1
-1
SimpleRouteLocatorTests.java
...k/cloud/netflix/zuul/filters/SimpleRouteLocatorTests.java
+11
-0
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/SimpleRouteLocator.java
View file @
d2155dc5
...
...
@@ -138,7 +138,7 @@ public class SimpleRouteLocator implements RouteLocator, Ordered {
}
String
targetPath
=
path
;
String
prefix
=
this
.
properties
.
getPrefix
();
if
(
path
.
startsWith
(
prefix
)
&&
this
.
properties
.
isStripPrefix
())
{
if
(
path
.
startsWith
(
prefix
+
"/"
)
&&
this
.
properties
.
isStripPrefix
())
{
targetPath
=
path
.
substring
(
prefix
.
length
());
}
if
(
route
.
isStripPrefix
())
{
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/filters/SimpleRouteLocatorTests.java
View file @
d2155dc5
...
...
@@ -24,6 +24,7 @@ import static org.hamcrest.CoreMatchers.hasItem;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
import
static
org
.
hamcrest
.
CoreMatchers
.
nullValue
;
import
static
org
.
hamcrest
.
collection
.
IsCollectionWithSize
.
hasSize
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
org.junit.Test
;
import
org.springframework.cloud.netflix.zuul.filters.ZuulProperties.ZuulRoute
;
...
...
@@ -59,6 +60,16 @@ public class SimpleRouteLocatorTests {
}
@Test
public
void
testStripPrefix
()
{
ZuulProperties
properties
=
new
ZuulProperties
();
properties
.
setPrefix
(
"/test"
);
properties
.
setStripPrefix
(
true
);
RouteLocator
locator
=
new
FilteringRouteLocator
(
"/"
,
properties
);
properties
.
getRoutes
().
put
(
"testservicea"
,
new
ZuulRoute
(
"/testservicea/**"
,
"testservicea"
));
assertEquals
(
"/test/testservicea/**"
,
locator
.
getRoutes
().
get
(
0
).
getFullPath
());
}
@Test
public
void
test_getMatchingRouteFilterRouteAcceptor
()
{
RouteLocator
locator
=
new
FilteringRouteLocator
(
"/"
,
this
.
zuul
);
this
.
zuul
.
getRoutes
().
clear
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment