use of org.apache.sling.api.request.RequestPathInfo in project sling by apache.
the class RequestProgressTrackerLogFilter method extractExtension.
private String extractExtension(SlingHttpServletRequest request) {
final RequestPathInfo requestPathInfo = request.getRequestPathInfo();
String extension = requestPathInfo.getExtension();
if (extension == null) {
final String pathInfo = requestPathInfo.getResourcePath();
final int extensionIndex = pathInfo.lastIndexOf('.') + 1;
extension = pathInfo.substring(extensionIndex);
}
return extension;
}
use of org.apache.sling.api.request.RequestPathInfo in project sling by apache.
the class SlingRequestPathInfoTest method testTrailingDotDotWithSuffix.
public void testTrailingDotDotWithSuffix() {
RequestPathInfo p = new SlingRequestPathInfo(new MockResource("/some/path", "../suffix"));
assertEquals("/some/path", p.getResourcePath());
assertNull("Selectors are null", p.getSelectorString());
assertEquals(0, p.getSelectors().length);
assertNull("Extension is null", p.getExtension());
assertEquals("/suffix", p.getSuffix());
}
use of org.apache.sling.api.request.RequestPathInfo in project sling by apache.
the class SlingRequestPathInfoTest method testPartialResolutionB.
public void testPartialResolutionB() {
RequestPathInfo p = new SlingRequestPathInfo(new MockResource("/some/path", ".print.a4.html/some/suffix"));
assertEquals("/some/path", p.getResourcePath());
assertEquals("print.a4", p.getSelectorString());
assertEquals(2, p.getSelectors().length);
assertEquals("print", p.getSelectors()[0]);
assertEquals("a4", p.getSelectors()[1]);
assertEquals("html", p.getExtension());
assertEquals("/some/suffix", p.getSuffix());
}
use of org.apache.sling.api.request.RequestPathInfo in project sling by apache.
the class SlingRequestPathInfoTest method testPathWithExtensionOnly.
public void testPathWithExtensionOnly() {
RequestPathInfo p = new SlingRequestPathInfo(new MockResource("/some/path/here.html", ""));
assertEquals("/some/path/here.html", p.getResourcePath());
assertNull("Selectors are null", p.getSelectorString());
assertEquals(0, p.getSelectors().length);
assertNull("Extension is null", p.getExtension());
assertNull("Suffix is null", p.getSuffix());
}
use of org.apache.sling.api.request.RequestPathInfo in project sling by apache.
the class SlingRequestPathInfoTest method testJIRA_250_d.
public void testJIRA_250_d() {
RequestPathInfo p = new SlingRequestPathInfo(new MockResource("/", ".json"));
assertEquals("/", p.getResourcePath());
assertEquals("json", p.getExtension());
assertNull("Suffix is null", p.getSuffix());
assertNull("Selectors are null", p.getSelectorString());
}
Aggregations