Skip to content

Commit

Permalink
cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanseifert committed Nov 17, 2023
1 parent 02d7d28 commit f4c104c
Showing 1 changed file with 2 additions and 27 deletions.
29 changes: 2 additions & 27 deletions src/main/java/io/wcm/wcm/ui/clientlibs/components/IncludeUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@

import java.lang.reflect.Array;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.xss.XSSAPI;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -114,7 +113,7 @@ else if (resourceResolver.getResource(library.getPath()) == null) {
if (customAttributesArray == null) {
return Collections.emptyMap();
}
Map<String, String> result = new LinkedHashMap<>();
Map<String, String> result = new HashMap<>();
for (String item : customAttributesArray) {
if (item != null) {
int separator = item.indexOf('=');
Expand All @@ -134,28 +133,4 @@ else if (resourceResolver.getResource(library.getPath()) == null) {
return result;
}

/**
* Builds opening HTML element with given name and attributes.
* @param elementName Element name
* @param attrs HTML attributes
* @param xssApi XSS API
* @return HTML element
*/
public static @NotNull String buildHtmlElementOpenTag(@NotNull String elementName, @NotNull Map<String, String> attrs,
XSSAPI xssApi) {
StringBuilder markup = new StringBuilder();
markup.append("<").append(elementName);
for (Map.Entry<String, String> attr : attrs.entrySet()) {
markup.append(" ");
markup.append(attr.getKey());
if (attr.getValue() != null) {
markup.append("=\"");
markup.append(xssApi.encodeForHTMLAttr(attr.getValue()));
markup.append("\"");
}
}
markup.append(">");
return markup.toString();
}

}

0 comments on commit f4c104c

Please sign in to comment.