Handle resources as URIs
Avoid unneccessary trailing /
This commit is contained in:
Greg Wilkins 2016-10-28 10:50:39 +11:00
parent cdf447e34e
commit 9f430ae7f7
3 changed files with 8 additions and 6 deletions

View File

@ -261,9 +261,11 @@ public class AttributeNormalizer
URI uri = null;
Path path = null;
if (o instanceof URI)
uri = ((URI)o).normalize();
uri = toCanonicalURI(((URI)o));
else if (o instanceof Resource)
uri = toCanonicalURI(((Resource)o).getURI());
else if (o instanceof URL)
uri = ((URL)o).toURI().normalize();
uri = toCanonicalURI(((URL)o).toURI());
else if (o instanceof File)
path = ((File)o).getAbsoluteFile().getCanonicalFile().toPath();
else if (o instanceof Path)

View File

@ -555,7 +555,7 @@ public class QuickStartDescriptorGenerator
Object o = _webApp.getAttribute(attribute);
if (o == null)
return;
Collection<?> c = (o instanceof Collection)? (Collection<?>)o:Collections.singletonList(o);
StringBuilder v=new StringBuilder();
for (Object i:c)

View File

@ -190,14 +190,14 @@ public class AttributeNormalizerTest
public void testNormalizeJettyBaseAsURI()
{
// Normalize jetty.base as URI path
assertNormalize(new File(jettyBase).toURI(), "${jetty.base.uri}/");
assertNormalize(new File(jettyBase).toURI(), "${jetty.base.uri}");
}
@Test
public void testNormalizeJettyHomeAsURI()
{
// Normalize jetty.home as URI path
assertNormalize(new File(jettyHome).toURI(), "${jetty.home.uri}/");
assertNormalize(new File(jettyHome).toURI(), "${jetty.home.uri}");
}
@Test
@ -219,7 +219,7 @@ public class AttributeNormalizerTest
{
// Normalize WAR as URI
URI testWarURI = new File(war).toURI();
assertNormalize(testWarURI, "${WAR.uri}/");
assertNormalize(testWarURI, "${WAR.uri}");
}
@Test