Permalink
Browse files

Stop slugify from eating leading/trailing single-letter words

  • Loading branch information...
1 parent 0373049 commit 2cc36e277569a2bf00549fb92ff88e3f808cc7a8 @dmnd dmnd committed Feb 15, 2012
Showing with 2 additions and 1 deletion.
  1. +1 −1 lib/underscore.string.js
  2. +1 −0 test/strings.js
View
2 lib/underscore.string.js
@@ -461,7 +461,7 @@
}
return str.replace(/[^a-z0-9 -]/g, '')
.replace(/\s+|\-+/g, '-')
- .replace(/^\-.|\-.$/g, '');
+ .replace(/^\-+|\-+$/g, '');
},
exports: function() {
View
1 test/strings.js
@@ -366,6 +366,7 @@ $(document).ready(function() {
test('Strings: slugify', function() {
equals(_("Jack & Jill like numbers 1,2,3 and 4 and silly characters ?%.$!/").slugify(), "jack-jill-like-numbers-123-and-4-and-silly-characters");
equals(_("Un éléphant à l'orée du bois").slugify(), "un-elephant-a-loree-du-bois");
+ equals(_("I am a word too, even though I am but a single letter: i!").slugify(), "i-am-a-word-too-even-though-i-am-but-a-single-letter--i");
});
});

0 comments on commit 2cc36e2

Please sign in to comment.