mirror of
https://github.com/esphome/esphome.git
synced 2025-09-10 15:22:24 +01:00
Ensure names containing characters other than a-z
A-Z
0-9
or _
are unique (#5810)
This commit is contained in:
@@ -357,6 +357,9 @@ def snake_case(value):
|
||||
return value.replace(" ", "_").lower()
|
||||
|
||||
|
||||
_DISALLOWED_CHARS = re.compile(r"[^a-zA-Z0-9_]")
|
||||
|
||||
|
||||
def sanitize(value):
|
||||
"""Same behaviour as `helpers.cpp` method `str_sanitize`."""
|
||||
return re.sub("[^-_0-9a-zA-Z]", r"", value)
|
||||
return _DISALLOWED_CHARS.sub("_", value)
|
||||
|
Reference in New Issue
Block a user