Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ public SlingUriBuilder rebaseResourcePath() {
selectors.clear();
extension = null;
suffix = null;
if (availableResourcePath.length() == path.length()) {
if (availableResourcePath.length() == path.length() || !path.contains(CHAR_DOT)) {
resourcePath = availableResourcePath;
} else {
setPathWithDefinedResourcePosition(path, availableResourcePath.length());
Expand Down
15 changes: 15 additions & 0 deletions src/test/java/org/apache/sling/api/uri/SlingUriTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.sling.api.uri;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.function.Consumer;

Expand Down Expand Up @@ -1024,6 +1025,20 @@ public void testHostWithoutSchemeAndQueryAndPath() {
assertEquals("//sling.apache.org", testUri.toUri().toASCIIString());
}

@Test
public void testWithSchemeAndMappedPathWithSlashAsLastCharacter() {
SlingUri testUri = SlingUriBuilder.parse("https://sling.apache.org/apidocs/sling12/", resolver)
.build();
assertEquals("https://sling.apache.org/apidocs/sling12", testUri.toUri().toASCIIString());
}

@Test
public void testWithSchemeAndMappedPathWithSlashAsLastCharacterCreateFromUri() throws URISyntaxException {
URI input = new URI("https://sling.apache.org/apidocs/sling12/");
SlingUri testUri = SlingUriBuilder.createFrom(input, resolver).build();
assertEquals("https://sling.apache.org/apidocs/sling12", testUri.toUri().toASCIIString());
}

// -- helper methods
public static void testUri(
String testUri,
Expand Down