Improve string to identifier transformation (#512)

Include all spaces characters (matching \s in a regex), not just the standard space character.
This commit is contained in:
Marc Wrobel
2025-09-08 17:45:45 +02:00
committed by GitHub
parent 26eef95fc5
commit c43a24fb19

View File

@@ -135,6 +135,6 @@ def list_products(products_dir: Path, product_name: str = None) -> list[ProductF
def to_identifier(s: str) -> str:
"""Convert a string to a valid endoflife.date identifier."""
identifier = s.strip().lower()
identifier = identifier.replace(" ", "-")
identifier = re.sub(r"\s+", "-", identifier)
identifier = re.sub(r"-+", "-", identifier)
return re.sub(r"[^a-z0-9.\-+_]", "", identifier)