diff --git a/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/link/LinkBuilderImpl.java b/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/link/LinkBuilderImpl.java
index c09988db76..d1ce9462b3 100644
--- a/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/link/LinkBuilderImpl.java
+++ b/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/link/LinkBuilderImpl.java
@@ -25,6 +25,7 @@
import org.apache.commons.lang3.tuple.Pair;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ValueMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -246,7 +247,10 @@ private String validateLinkAttributeValue(@Nullable final String value) {
*/
@NotNull
private String getPageLinkURL(@NotNull Page page) {
- return page.getPath() + HTML_EXTENSION;
+ Resource resource = page.adaptTo(Resource.class);
+ assert resource!=null;
+ ResourceResolver resolver = resource.getResourceResolver();
+ return resolver.map(page.getPath()) + HTML_EXTENSION;
}
/**
diff --git a/bundles/core/src/test/java/com/adobe/cq/wcm/core/components/commons/link/LinkManagerTest.java b/bundles/core/src/test/java/com/adobe/cq/wcm/core/components/commons/link/LinkManagerTest.java
index 734c260370..5860040517 100644
--- a/bundles/core/src/test/java/com/adobe/cq/wcm/core/components/commons/link/LinkManagerTest.java
+++ b/bundles/core/src/test/java/com/adobe/cq/wcm/core/components/commons/link/LinkManagerTest.java
@@ -113,7 +113,7 @@ void testResourcePageLink() {
PN_LINK_URL, page.getPath());
context.currentResource(linkResource);
Link link = getUnderTest().get(linkResource).build();
- assertValidLink(link, page.getPath() + ".html");
+ assertValidLink(link, context.resourceResolver().map(page.getPath()) + ".html");
assertEquals(page, link.getReference());
assertEquals((page.getPath() + ".html").replaceAll("^\\/content\\/links\\/site1\\/(.+)","/content/site1/$1"),
link.getMappedURL());
@@ -142,8 +142,8 @@ void testResourceInvalidPageLink() {
void testPageLink() {
Link link = getUnderTest().get(page).build();
- assertValidLink(link, page.getPath() + ".html");
- assertEquals("https://example.org" + page.getPath() + ".html", link.getExternalizedURL());
+ assertValidLink(link, context.resourceResolver().map(page.getPath()) + ".html");
+ assertEquals("https://example.org" + context.resourceResolver().map(page.getPath()) + ".html", link.getExternalizedURL());
assertEquals(page, link.getReference());
}
@@ -167,7 +167,7 @@ void testEmptyLink() {
void testLinkURLPageLinkWithTarget() {
Link link = getUnderTest().get(page.getPath()).withLinkTarget("_blank").build();
- assertValidLink(link, page.getPath() + ".html", "_blank");
+ assertValidLink(link, context.resourceResolver().map(page.getPath()) + ".html", "_blank");
assertEquals(page, link.getReference());
}
@@ -198,8 +198,8 @@ void testLinkWithRedirect() {
Link link = getUnderTest().get(linkResource).build();
assertTrue(link.isValid());
- assertValidLink(link, targetPage2.getPath() + ".html");
- assertEquals("https://example.org" + targetPage2.getPath() + ".html", link.getExternalizedURL());
+ assertValidLink(link, context.resourceResolver().map(targetPage2.getPath()) + ".html");
+ assertEquals("https://example.org" + context.resourceResolver().map(targetPage2.getPath()) + ".html", link.getExternalizedURL());
assertEquals(targetPage2, link.getReference());
}
@@ -225,8 +225,8 @@ void testLinkWithRedirect_shadowingDisabledByProperty() {
Link link = getUnderTest().get(linkResource).build();
assertTrue(link.isValid());
- assertValidLink(link, targetPage1.getPath() + ".html");
- assertEquals("https://example.org" + targetPage1.getPath() + ".html", link.getExternalizedURL());
+ assertValidLink(link, context.resourceResolver().map(targetPage1.getPath()) + ".html");
+ assertEquals("https://example.org" + context.resourceResolver().map(targetPage1.getPath()) + ".html", link.getExternalizedURL());
assertEquals(targetPage1, link.getReference());
}
@@ -255,8 +255,8 @@ void testLinkWithRedirect_shadowingDisabledByStyle() {
Link link = getUnderTest().get(linkResource).build();
assertTrue(link.isValid());
- assertValidLink(link, targetPage1.getPath() + ".html");
- assertEquals("https://example.org" + targetPage1.getPath() + ".html", link.getExternalizedURL());
+ assertValidLink(link, context.resourceResolver().map(targetPage1.getPath()) + ".html");
+ assertEquals("https://example.org" + context.resourceResolver().map(targetPage1.getPath()) + ".html", link.getExternalizedURL());
assertEquals(targetPage1, link.getReference());
}
diff --git a/bundles/core/src/test/java/com/adobe/cq/wcm/core/components/internal/link/DefaultPathProcessorTest.java b/bundles/core/src/test/java/com/adobe/cq/wcm/core/components/internal/link/DefaultPathProcessorTest.java
index 72d1ca9dac..56fc56e288 100644
--- a/bundles/core/src/test/java/com/adobe/cq/wcm/core/components/internal/link/DefaultPathProcessorTest.java
+++ b/bundles/core/src/test/java/com/adobe/cq/wcm/core/components/internal/link/DefaultPathProcessorTest.java
@@ -117,7 +117,7 @@ void testVanityConfig() {
DefaultPathProcessor underTest = context.registerInjectActivateService(new DefaultPathProcessor(), ImmutableMap.of(
"vanityConfig", "shouldBeDefault"));
assertEquals("/content/site1/en.html", underTest.map(page.getPath() + HTML_EXTENSION, context.request()));
- assertEquals("https://example.org/content/links/site1/en.html", underTest.externalize(page.getPath() + HTML_EXTENSION, context.request()));
+ assertEquals("https://example.org/content/site1/en.html", underTest.externalize(page.getPath() + HTML_EXTENSION, context.request()));
context.request().setContextPath("/cp");
underTest = context.registerInjectActivateService(new DefaultPathProcessor(), ImmutableMap.of(
"vanityConfig", DefaultPathProcessor.VanityConfig.ALWAYS.getValue()));
diff --git a/parent/pom.xml b/parent/pom.xml
index f365950558..d76fa2cc78 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -796,7 +796,7 @@
io.wcm
io.wcm.testing.aem-mock.junit5
- 5.5.2
+ 5.6.2
test