From 4222ada667c174042d9d928da4c064e43cce49d1 Mon Sep 17 00:00:00 2001 From: Jay Hemnani <193022578+jayhemnani9910@users.noreply.github.com> Date: Sat, 14 Nov 2026 02:56:35 +0530 Subject: [PATCH] =?UTF-8?q?fix(strings):=20transliterate=20=C3=9F,=20?= =?UTF-8?q?=C3=A6,=20=C3=B8=20and=20=C5=81=20in=20slugify?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit slugify relied on NFKD + ASCII encoding, which deletes letters that have no decomposition, so "Ærøskøbing" became "rskbing" and "Straße" "strae". Run the text through deburr first, which maps these letters. --- AUTHORS.rst | 1 + CHANGELOG.rst | 2 ++ src/pydash/strings.py | 2 +- tests/test_strings.py | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/AUTHORS.rst b/AUTHORS.rst index 3962f66e..ac8e6c9f 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -88,3 +88,4 @@ Contributors - wynneyin, `wynneyin@github `_ - Arin Aeruva, `arin30@github `_ - Cyber Marty, `Cyber-Marty@github `_ +- Jay Hemnani, `jayhemnani9910@github `_ diff --git a/CHANGELOG.rst b/CHANGELOG.rst index cc415a7b..e5f07661 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,8 @@ Changelog Unreleased ---------- +- Transliterate letters like ``ß``, ``æ``, ``ø`` and ``Ł`` in ``slugify`` through ``deburr`` instead of + dropping them. - Stop ``partial`` and ``partial_right`` wrappers from accepting a positional iteratee argument in a slot that a keyword argument already binds, so ``map_`` passes the element instead of an index into the bound parameter. diff --git a/src/pydash/strings.py b/src/pydash/strings.py index 30ee60c3..977fa682 100644 --- a/src/pydash/strings.py +++ b/src/pydash/strings.py @@ -1728,7 +1728,7 @@ def slugify(text: t.Any, separator: str = "-") -> str: Remove single quotes from output. """ normalized = ( - unicodedata.normalize("NFKD", pyd.to_string(text)) + unicodedata.normalize("NFKD", deburr(pyd.to_string(text))) .encode("ascii", "ignore") .decode("utf8") .replace("'", "") diff --git a/tests/test_strings.py b/tests/test_strings.py index 8708b452..8aff9a45 100644 --- a/tests/test_strings.py +++ b/tests/test_strings.py @@ -898,6 +898,7 @@ def test_series_phrase_serial(case, expected): (" foo bar ", "foo-bar"), ("Un éléphant à l'orée du bois", "un-elephant-a-loree-du-bois"), ("shouldn't couldn't wouldn't", "shouldnt-couldnt-wouldnt"), + ("Ærøskøbing Straße", "aeroskobing-strasse"), ("", ""), (5, "5"), (None, ""),