summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVal Neekman <un33kvu@gmail.com>2015-12-12 11:15:21 -0500
committerVal Neekman <un33kvu@gmail.com>2015-12-12 11:15:21 -0500
commiteeabcc29eb67dd9ab34c693db44f9ece312e7a2c (patch)
treeb5e9f1cc5cdd5c03f9e8afd1834870aaaf7123bb
parent4091b444746032847ccce0d5c6a0cd5b1bb73d81 (diff)
parenta1543fe0ae019606bec660d6cf2e70a435ff29e4 (diff)
downloadpython-slugify-eeabcc29eb67dd9ab34c693db44f9ece312e7a2c.tar.gz
Merge pull request #22 from lucaswo/master
Stopword replacement bug (different separators)
-rw-r--r--slugify/slugify.py4
-rw-r--r--test.py5
2 files changed, 7 insertions, 2 deletions
diff --git a/slugify/slugify.py b/slugify/slugify.py
index 03588a1..9eeabef 100644
--- a/slugify/slugify.py
+++ b/slugify/slugify.py
@@ -129,8 +129,8 @@ def slugify(text, entities=True, decimal=True, hexadecimal=True, max_length=0, w
# remove stopwords
if stopwords:
stopwords_lower = [s.lower() for s in stopwords]
- words = [w for w in text.split(separator) if w not in stopwords_lower]
- text = separator.join(words)
+ words = [w for w in text.split('-') if w not in stopwords_lower]
+ text = '-'.join(words)
# smart truncate if requested
if max_length > 0:
diff --git a/test.py b/test.py
index 7f039a2..c5e6265 100644
--- a/test.py
+++ b/test.py
@@ -131,6 +131,11 @@ class TestSlugification(unittest.TestCase):
r = slugify(txt, stopwords=['the', 'in', 'a', 'hurry'])
self.assertEqual(r, 'quick-brown-fox-jumps-over-lazy-dog')
+ def test_stopwords_with_different_separator(self):
+ txt = 'the quick brown fox jumps over the lazy dog'
+ r = slugify(txt, stopwords=['the'], separator=' ')
+ self.assertEqual(r, 'quick brown fox jumps over lazy dog')
+
def test_html_entities(self):
txt = 'foo &amp; bar'
r = slugify(txt)