mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
Strip leading and trailing slug punctuation.
This commit is contained in:
parent
415f810089
commit
ee8d68842e
2 changed files with 8 additions and 0 deletions
|
@ -23,6 +23,7 @@ module Slug
|
|||
str.gsub!(/[^a-z0-9 -]/, '')
|
||||
str.gsub!(/\s+/, '-')
|
||||
str.gsub!(/\-+/, '-')
|
||||
str.gsub!(/^-|-$/, '')
|
||||
|
||||
str
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue