Merge pull request #51 from danneu/slug-patch

Strip leading and trailing slug punctuation.
This commit is contained in:
Robin Ward 2013-02-07 07:02:58 -08:00
commit d49cf88c35
2 changed files with 8 additions and 0 deletions

View File

@ -23,6 +23,7 @@ module Slug
str.gsub!(/[^a-z0-9 -]/, '')
str.gsub!(/\s+/, '-')
str.gsub!(/\-+/, '-')
str.gsub!(/^-|-$/, '')
str
end

View File

@ -27,6 +27,13 @@ describe Slug do
Slug.for("a....b.....c").should == "a-b-c"
end
it 'strips trailing punctuation' do
Slug.for("hello...").should == "hello"
end
it 'strips leading punctuation' do
Slug.for("...hello").should == "hello"
end
end