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
c79ac8ba
Commit
c79ac8ba
authored
Jan 17, 2018
by
Ryan Baxter
Committed by
Spencer Gibb
Jan 17, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove / from prefix if present.
Fixes #2625
parent
a399cca7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
0 deletions
+12
-0
SimpleRouteLocator.java
...mework/cloud/netflix/zuul/filters/SimpleRouteLocator.java
+3
-0
SimpleRouteLocatorTests.java
...k/cloud/netflix/zuul/filters/SimpleRouteLocatorTests.java
+9
-0
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/SimpleRouteLocator.java
View file @
c79ac8ba
...
...
@@ -138,6 +138,9 @@ public class SimpleRouteLocator implements RouteLocator, Ordered {
}
String
targetPath
=
path
;
String
prefix
=
this
.
properties
.
getPrefix
();
if
(
prefix
.
endsWith
(
"/"
))
{
prefix
=
prefix
.
substring
(
0
,
prefix
.
length
()
-
1
);
}
if
(
path
.
startsWith
(
prefix
+
"/"
)
&&
this
.
properties
.
isStripPrefix
())
{
targetPath
=
path
.
substring
(
prefix
.
length
());
}
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/filters/SimpleRouteLocatorTests.java
View file @
c79ac8ba
...
...
@@ -70,6 +70,15 @@ public class SimpleRouteLocatorTests {
}
@Test
public
void
testPrefix
()
{
ZuulProperties
properties
=
new
ZuulProperties
();
properties
.
setPrefix
(
"/test/"
);
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