Skip to content

Commit

Permalink
Support "dash" in HtmlTagIntegrityChecker
Browse files Browse the repository at this point in the history
  • Loading branch information
ja-openai committed Sep 3, 2024
1 parent a87c783 commit a3ffeb3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class HtmlTagIntegrityChecker extends RegexIntegrityChecker {

@Override
public String getRegex() {
return "(<\\w+(\\s+\\w+(\\s*=\\s*('([^']*?)'|\"([^\"]*?)\"))?)*\\s*/?>|</\\w+>)";
return "(<[a-zA-Z][\\w-]*(\\s+\\w+(\\s*=\\s*('([^']*?)'|\"([^\"]*?)\"))?)*\\s*/?>|<\\/[a-zA-Z][\\w-]*>)";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.box.l10n.mojito.service.assetintegritychecker.integritychecker;

import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -68,7 +68,7 @@ Pattern getPattern() {
*/
Set<String> getPlaceholders(String string) {

Set<String> placeholders = new HashSet<>();
Set<String> placeholders = new LinkedHashSet<>();

if (string != null) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.box.l10n.mojito.service.assetintegritychecker.integritychecker;

import java.util.Set;
import org.assertj.core.api.Assertions;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -191,4 +193,12 @@ public void testHtmlTagCheckNonTagLessThanDoesntConfuseThings() {

checker.check(source, target);
}

@Test
public void testHtmlTagCheckWithDash() {
String source = "<sign-up>Mag-sign up</sign-up> o <login> upang </login>";
Set<String> placeholders = checker.getPlaceholders(source);
Assertions.assertThat(placeholders)
.containsExactly("<sign-up>", "</sign-up>", "<login>", "</login>");
}
}

0 comments on commit a3ffeb3

Please sign in to comment.