diff --git a/src/main/java/com/endava/cats/generator/simple/StringGenerator.java b/src/main/java/com/endava/cats/generator/simple/StringGenerator.java index 7b20a8ea2..ad8988c89 100755 --- a/src/main/java/com/endava/cats/generator/simple/StringGenerator.java +++ b/src/main/java/com/endava/cats/generator/simple/StringGenerator.java @@ -90,6 +90,7 @@ public class StringGenerator { private static final org.cornutum.regexpgen.Provider REGEXPGEN_PROVIDER = Provider.forEcmaScript(); private static final PrettyLogger LOGGER = PrettyLoggerFactory.getLogger(StringGenerator.class); + public static final String CASE_INSENSITIVE = "\\(\\?i\\)"; private StringGenerator() { //ntd @@ -180,6 +181,7 @@ public static String cleanPattern(String pattern) { pattern = StringUtils.removeEnd(pattern, "/"); } pattern = pattern.replaceAll(EMPTY_PATTERN, EMPTY); + pattern = pattern.replaceAll(CASE_INSENSITIVE, EMPTY); return pattern; } diff --git a/src/test/java/com/endava/cats/generator/simple/StringGeneratorTest.java b/src/test/java/com/endava/cats/generator/simple/StringGeneratorTest.java index e8aa86249..06d0e94ae 100644 --- a/src/test/java/com/endava/cats/generator/simple/StringGeneratorTest.java +++ b/src/test/java/com/endava/cats/generator/simple/StringGeneratorTest.java @@ -128,4 +128,10 @@ void shouldGenerateWhenOrEmpty() { String generated = StringGenerator.generate("^$|^(?i)(http:\\/\\/|https:\\/\\/)([a-z0-9./\\-_.~+=:;%&?]+)$", 100, 100); Assertions.assertThat(generated).hasSize(100).matches("^(?i)(http://|https://)([a-z0-9./\\-_.~+=:;%&?]+)"); } + + @Test + void shouldRemoveCaseInsensitive() { + String generated = StringGenerator.cleanPattern("^(?i)(http:\\/\\/|https:\\/\\/)([a-z0-9./\\-_.~+=:;%&?]+)$"); + Assertions.assertThat(generated).isEqualTo("^(http:\\/\\/|https:\\/\\/)([a-z0-9./\\-_.~+=:;%&?]+)$"); + } }