Merge "Replace double dashes with a simple dash in Prolog generated label names"

This commit is contained in:
Maxime Guerreiro
2018-07-02 08:19:04 +00:00
committed by Gerrit Code Review
2 changed files with 5 additions and 4 deletions

View File

@@ -297,7 +297,8 @@ public class PrologRuleEvaluator {
try {
return LabelType.checkName(name);
} catch (IllegalArgumentException e) {
return LabelType.checkName("Invalid-Prolog-Rules-Label-Name--" + sanitizeLabelName(name));
String newName = "Invalid-Prolog-Rules-Label-Name-" + sanitizeLabelName(name);
return LabelType.checkName(newName.replace("--", "-"));
}
}

View File

@@ -30,18 +30,18 @@ public class PrologRuleEvaluatorTest {
@Test
public void labelWithSpacesIsTransformed() {
assertThat(PrologRuleEvaluator.checkLabelName("Label with spaces"))
.isEqualTo("Invalid-Prolog-Rules-Label-Name--Labelwithspaces");
.isEqualTo("Invalid-Prolog-Rules-Label-Name-Labelwithspaces");
}
@Test
public void labelStartingWithADashIsTransformed() {
assertThat(PrologRuleEvaluator.checkLabelName("-dashed-label"))
.isEqualTo("Invalid-Prolog-Rules-Label-Name---dashed-label");
.isEqualTo("Invalid-Prolog-Rules-Label-Name-dashed-label");
}
@Test
public void labelWithInvalidCharactersIsTransformed() {
assertThat(PrologRuleEvaluator.checkLabelName("*urgent*"))
.isEqualTo("Invalid-Prolog-Rules-Label-Name--urgent");
.isEqualTo("Invalid-Prolog-Rules-Label-Name-urgent");
}
}