Skip to content

Commit

Permalink
Merge branch 'master' into feature/remove-contentsync.handler-dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjgonzalez authored Oct 1, 2024
2 parents 71434cc + 4f4f18c commit 1df5021
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com)
- #3420 - Redirect Map Manager - enable Redirect Map Manager in AEM CS (would require a specific - not public yet - AEM CS release version, TBA)
- #3429 - UI Widgets - add uniq function to embedded lodash library to resolve issue with composite multifield widget
- #3423 - Redirect Manager - status code is not retaining its value in the dialog after authoring
- #3417 - Configurable recursion in Content Sync

### Fixed

- #3413 - Redirect Manager: Interface triggers an error because of wrong deprecated resource type

## 6.6.4 - 2024-08-14

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,11 @@ private String handleMatchingPatternAttribute(Pattern pattern, String attrValue)
url = prependHostName(url);
// Added check to determine whether the existing host has to be replaced
if (this.replaceHost) {
int index = attrValue.indexOf("://");
sb.setLength(0);
sb.append(attrValue, 0, index + 1);
if (!url.contains("://")) {
String reuseScheme = attrValue.substring(0, attrValue.indexOf("://") + 1);
sb.append(reuseScheme);
}
sb.append(url);
} else {
m.appendReplacement(sb, Matcher.quoteReplacement(url));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.only;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.*;

import java.util.List;

Expand Down Expand Up @@ -124,28 +122,40 @@ public void test_with_prefix_and_matching_pattern_and_single_host() throws Excep

@Test
public void test_with_prefix_and_matching_pattern_and_single_host_and_replace_host() throws Exception {
test_with_prefix_and_matching_pattern_and_single_host_and_replace_host_custom_scheme(null);
test_with_prefix_and_matching_pattern_and_single_host_and_replace_host_custom_scheme("https");
test_with_prefix_and_matching_pattern_and_single_host_and_replace_host_custom_scheme("http");
}

private void test_with_prefix_and_matching_pattern_and_single_host_and_replace_host_custom_scheme(String scheme) throws Exception {
MockBundle bundle = new MockBundle(-1);
MockComponentContext ctx = new MockComponentContext(bundle);
ctx.setProperty("prefixes", new String[] { "/content/dam" });
ctx.setProperty("attributes", new String[] { "img:src" });
ctx.setProperty("host.pattern", "static.host.com");
ctx.setProperty("matchingPatterns", "img:src;(\\/content\\/dam\\/.+?\\.(png|jpg))");
ctx.setProperty("replaceHost", true);
if (scheme != null) {
ctx.setProperty("host.scheme", scheme);
}

StaticReferenceRewriteTransformerFactory factory = new StaticReferenceRewriteTransformerFactory();
factory.activate(ctx);

reset(handler);
Transformer transformer = factory.createTransformer();
transformer.setContentHandler(handler);

AttributesImpl imageWithJustSrc = new AttributesImpl();
imageWithJustSrc.addAttribute(null, "src", null, "CDATA", "https://www.host.com/content/dam/flower.jpg");
String inputUrl = "https://www.host.com/content/dam/flower.jpg";
imageWithJustSrc.addAttribute(null, "src", null, "CDATA", inputUrl);
transformer.startElement(null, "img", null, imageWithJustSrc);

verify(handler, only()).startElement(isNull(), eq("img"), isNull(),
attributesCaptor.capture());
List<Attributes> values = attributesCaptor.getAllValues();
assertEquals("https://static.host.com/content/dam/flower.jpg", values.get(0).getValue(0));
String expectedScheme = scheme == null ? inputUrl.substring(0, inputUrl.indexOf("://")) : scheme;
assertEquals(expectedScheme + "://static.host.com/content/dam/flower.jpg", values.get(values.size() - 1).getValue(0));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,18 @@
$.ajax({
url: redirectPath + ".html"
}).done(function (trHtml) {
var tr;
if (response.isCreate) {
var editRedirectTable = $(TABLE_SELECTOR);
var tr = editRedirectTable
tr = editRedirectTable
.find("tbody")[0]
.appendChild(document.createElement("tr"));
$(tr).replaceWith(trHtml);
tr.id = redirectId;
tr.dataset.path = redirectPath;
} else {
$("#" + redirectId).replaceWith(trHtml);
tr = $("#" + redirectId)[0];
}
tr.innerHTML = trHtml;
var ui = $(window).adaptTo("foundation-ui");
ui.clearWait();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--
~ ACS AEM Commons
~
~ Copyright (C) 2013 - 2023 Adobe
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
--><!--
Render a redirect as html.
Used by the "Configure Redirection Rule" dialog to update the table of redirects
-->
<sly
data-sly-use.redirectsTemplate="../template.html"
data-sly-call="${redirectsTemplate.row @ redirectResource = resource, allowRearrange = true}"
/>

0 comments on commit 1df5021

Please sign in to comment.