From db989731fef6343079bdd1e1e52edf28f6a10b3e Mon Sep 17 00:00:00 2001 From: oyeong011 Date: Tue, 8 Sep 2026 10:07:49 +0900 Subject: [PATCH] Preserve case-sensitive stopword filtering for iterators Constraint: Keep the documented Iterable input contract and Python version floor. Confidence: high Scope-risk: narrow Tested: Full suite with both transliterators, mypy, pycodestyle, API and CLI checks. --- slugify/slugify.py | 1 + test.py | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/slugify/slugify.py b/slugify/slugify.py index 9b5f27f..bfe19f2 100644 --- a/slugify/slugify.py +++ b/slugify/slugify.py @@ -179,6 +179,7 @@ def slugify( stopwords_lower = [s.lower() for s in stopwords] words = [w for w in text.split(DEFAULT_SEPARATOR) if w not in stopwords_lower] else: + stopwords = set(stopwords) words = [w for w in text.split(DEFAULT_SEPARATOR) if w not in stopwords] text = DEFAULT_SEPARATOR.join(words) diff --git a/test.py b/test.py index fcec4b6..a9ac1c3 100644 --- a/test.py +++ b/test.py @@ -127,6 +127,15 @@ def test_stopword_removal_casesensitive(self): r = slugify(txt, stopwords=['Stopword'], lowercase=False) self.assertEqual(r, 'thIs-Has-a-stopword') + def test_stopword_iterator_casesensitive(self): + for allow_unicode in (False, True): + with self.subTest(allow_unicode=allow_unicode): + words = iter(['Stopword', 'Other']) + result = slugify('Keep Stopword Other Stopword stopword', + stopwords=words, lowercase=False, + allow_unicode=allow_unicode) + self.assertEqual(result, 'Keep-stopword') + def test_multiple_stopword_occurances(self): txt = 'the quick brown fox jumps over the lazy dog' r = slugify(txt, stopwords=['the'])