Fix ResourceUrlProvider path check in getForRequestUrl

Prior to this change, getForRequestUrl implementation would only work
for applications with a non-empty servlet path. So web applications
mapped to "/" would trigger a IllegalStateException while checking the
current request against the request path within the current mapping.

This change relaxes this and only check that the path within mapping is
within the request URL.

Issue: SPR-12158
This commit is contained in:
Brian Clozel
2014-09-05 22:46:13 +02:00
parent 1c2857d15e
commit 6aef1a1d17
2 changed files with 27 additions and 2 deletions

View File

@@ -180,7 +180,7 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed
}
int index = getPathHelper().getRequestUri(request).indexOf(pathWithinMapping);
Assert.state(index > 0 && index < requestUrl.length(), "Failed to determine lookup path: " + requestUrl);
Assert.state(index != -1, "Failed to determine lookup path: " + requestUrl);
String prefix = requestUrl.substring(0, index);
String lookupPath = requestUrl.substring(index);