Commit c79ac8ba by Ryan Baxter Committed by Spencer Gibb

Remove / from prefix if present.

Fixes #2625
parent a399cca7
......@@ -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());
}
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment