mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
* Better handling of accented characters in slugify (#4399) * Update __init__.py
This commit is contained in:
parent
f006b00dc1
commit
b0e3d5a576
@ -10,6 +10,7 @@ import random
|
||||
import string
|
||||
from functools import wraps
|
||||
from types import MappingProxyType
|
||||
from unicodedata import normalize
|
||||
|
||||
from typing import Any, Optional, TypeVar, Callable, Sequence, KeysView, Union
|
||||
|
||||
@ -35,7 +36,7 @@ def sanitize_path(path: str) -> str:
|
||||
|
||||
def slugify(text: str) -> str:
|
||||
"""Slugify a given text."""
|
||||
text = text.lower().replace(" ", "_")
|
||||
text = normalize('NFKD', text).lower().replace(" ", "_")
|
||||
|
||||
return RE_SLUGIFY.sub("", text)
|
||||
|
||||
|
@ -30,6 +30,7 @@ class TestUtil(unittest.TestCase):
|
||||
self.assertEqual("test", util.slugify("T-!@#$!#@$!$est"))
|
||||
self.assertEqual("test_more", util.slugify("Test More"))
|
||||
self.assertEqual("test_more", util.slugify("Test_(More)"))
|
||||
self.assertEqual("test_more", util.slugify("Tèst_Mörê"))
|
||||
|
||||
def test_repr_helper(self):
|
||||
"""Test repr_helper."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user