diff --git a/plugins/module_utils/netbox_utils.py b/plugins/module_utils/netbox_utils.py index 134fefd37..e80b7a497 100644 --- a/plugins/module_utils/netbox_utils.py +++ b/plugins/module_utils/netbox_utils.py @@ -1162,8 +1162,10 @@ def _to_slug(self, value): return value else: removed_chars = re.sub(r"[^\-\.\w\s]", "", value) + removed_chars = removed_chars.encode('ascii', errors="ignore").decode() + removed_chars = removed_chars.strip() convert_chars = re.sub(r"[\-\.\s]+", "-", removed_chars) - return convert_chars.strip().lower() + return convert_chars.lower() def _normalize_data(self, data): """ diff --git a/tests/unit/module_utils/test_data/normalize_data/data.json b/tests/unit/module_utils/test_data/normalize_data/data.json index be7f861d2..f6d2438b0 100644 --- a/tests/unit/module_utils/test_data/normalize_data/data.json +++ b/tests/unit/module_utils/test_data/normalize_data/data.json @@ -217,7 +217,7 @@ }, { "before": { - "slug": "Test to_slug" + "slug": "Test to_slug© ⅛ äüöß 👀" }, "after": { "slug": "test-to_slug" @@ -345,4 +345,4 @@ "mac_address": "AA:BB:CC:DD:EE:FF" } } -] \ No newline at end of file +]