Decode resourcePath for classpath locations
Closes gh-22272
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,6 +22,7 @@ import java.util.List;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.FileUrlResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.UrlResource;
|
||||
|
||||
@@ -64,6 +65,22 @@ public class PathResourceResolverTests {
|
||||
assertNotNull(actual);
|
||||
}
|
||||
|
||||
@Test // gh-22272
|
||||
public void resolveWithEncodedPath() throws IOException {
|
||||
Resource classpathLocation = new ClassPathResource("test/", PathResourceResolver.class);
|
||||
testWithEncodedPath(classpathLocation);
|
||||
testWithEncodedPath(new FileUrlResource(classpathLocation.getURL()));
|
||||
}
|
||||
|
||||
private void testWithEncodedPath(Resource location) throws IOException {
|
||||
String path = "foo%20foo.txt";
|
||||
List<Resource> locations = singletonList(location);
|
||||
Resource actual = this.resolver.resolveResource(null, path, locations, null).block(TIMEOUT);
|
||||
|
||||
assertNotNull(actual);
|
||||
assertEquals("foo foo.txt", actual.getFile().getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkResource() throws IOException {
|
||||
Resource location = new ClassPathResource("test/", PathResourceResolver.class);
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Also some text.
|
||||
Reference in New Issue
Block a user