Skip to content

Commit

Permalink
tweaks regex
Browse files Browse the repository at this point in the history
  • Loading branch information
msbarry committed Nov 26, 2024
1 parent e049876 commit c43db46
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class LanguageUtils {
// See https://wiki.openstreetmap.org/wiki/Multilingual_names
public static final Predicate<String> VALID_NAME_TAGS =
Pattern
.compile("^name:[a-z]{2,3}(-[a-z]{4})?([-_](x-)?[a-z]{2,})?(-([a-z]{2}|\\d{3}))?$", Pattern.CASE_INSENSITIVE)
.compile("^name:[a-z]{2,3}(-[A-Z][a-z]{3})?([-_](x-)?[a-z]{2,})?(-([A-Z]{2}|\\d{3}))?$")
.asMatchPredicate();
// See https://github.com/onthegomap/planetiler/issues/86
// Match strings that only contain latin characters.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ void testRemoveNonLatin(String in, String out) {
@CsvSource(value = {
"name:es, true",
"name:en-US, true",
"name:en-001, true",
"name:fr-x-gallo, true",
"name:ko-Latn, true",
"name:be-tarask, true",
Expand All @@ -45,6 +46,11 @@ void testRemoveNonLatin(String in, String out) {
"nombre, false",
"name:, false",
"name:xxxxx, false",
"name:tec, true",
"name:TEC, false",
"name:be-tarask, true",
"name:nan-Latn-pehoeji, true",
"name:zh-Latn-pinyin, true",
}, nullValues = "null")
void testIsValidOsmNameTag(String in, boolean out) {
assertEquals(out, LanguageUtils.isValidOsmNameTag(in));
Expand Down

0 comments on commit c43db46

Please sign in to comment.