Polish WebJarsResourceResolver
Follow up to accb8519fd - same fix when resolving missing resources or
resolving a public URL for these resources.
This commit is contained in:
@@ -63,7 +63,9 @@ public class WebJarsResourceResolver extends AbstractResourceResolver {
|
|||||||
Resource resolved = chain.resolveResource(request, requestPath, locations);
|
Resource resolved = chain.resolveResource(request, requestPath, locations);
|
||||||
if (resolved == null) {
|
if (resolved == null) {
|
||||||
String webJarResourcePath = findWebJarResourcePath(requestPath);
|
String webJarResourcePath = findWebJarResourcePath(requestPath);
|
||||||
return chain.resolveResource(request, webJarResourcePath, locations);
|
if(webJarResourcePath != null) {
|
||||||
|
return chain.resolveResource(request, webJarResourcePath, locations);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return resolved;
|
return resolved;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ public class WebJarsResourceResolverTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void resolverUrlWebJarResourceNotFound() {
|
public void resolveUrlWebJarResourceNotFound() {
|
||||||
String file = "/something/something.js";
|
String file = "/something/something.js";
|
||||||
given(this.chain.resolveUrlPath(file, this.locations)).willReturn(null);
|
given(this.chain.resolveUrlPath(file, this.locations)).willReturn(null);
|
||||||
|
|
||||||
@@ -123,6 +123,18 @@ public class WebJarsResourceResolverTests {
|
|||||||
verify(this.chain, times(1)).resolveResource(this.request, file, this.locations);
|
verify(this.chain, times(1)).resolveResource(this.request, file, this.locations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void resolveResourceNotFound() {
|
||||||
|
String file = "/something/something.js";
|
||||||
|
given(this.chain.resolveUrlPath(file, this.locations)).willReturn(null);
|
||||||
|
|
||||||
|
Resource actual = this.resolver.resolveResource(this.request, file, this.locations, this.chain);
|
||||||
|
|
||||||
|
assertNull(actual);
|
||||||
|
verify(this.chain, times(1)).resolveResource(this.request, file, this.locations);
|
||||||
|
verify(this.chain, never()).resolveResource(this.request, null, this.locations);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void resolveResourceWebJar() {
|
public void resolveResourceWebJar() {
|
||||||
Resource expected = mock(Resource.class);
|
Resource expected = mock(Resource.class);
|
||||||
|
|||||||
Reference in New Issue
Block a user