regex to be more restrictive and consistent

This commit is contained in:
Fabio Bozzo
2024-12-02 18:30:41 +01:00
parent 117a75e2c4
commit 15751c7362
2 changed files with 2 additions and 3 deletions

View File

@@ -22,8 +22,7 @@ var (
// \p{Mn}\p{Mc} - combining marks and spacing combining marks // \p{Mn}\p{Mc} - combining marks and spacing combining marks
// \p{Nd} - decimal numbers // \p{Nd} - decimal numbers
// \p{Pc} - connector punctuation (like underscore) // \p{Pc} - connector punctuation (like underscore)
// \p{Sm}\p{So} - math symbols and other symbols fieldRegex = regexp.MustCompile(`^\.[a-zA-Z_\p{L}][a-zA-Z$_\p{L}\p{Mn}\p{Mc}\p{Nd}\p{Pc}-]*?$`)
fieldRegex = regexp.MustCompile(`^\.[a-zA-Z_\p{L}][a-zA-Z$_\p{L}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\p{Sm}\p{So}-]*?$`)
) )
func Parse(str string) (Selector, error) { func Parse(str string) (Selector, error) {

View File

@@ -591,7 +591,7 @@ func TestParse(t *testing.T) {
".mixed_kebab-case", ".mixed_kebab-case",
".with$dollar", ".with$dollar",
".MIXED_Case_123", ".MIXED_Case_123",
".unicode", ".unicodeø",
} }
for _, field := range validFields { for _, field := range validFields {