mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 15:48:43 -05:00
omit single quotes from slug
This commit is contained in:
parent
1833c124d9
commit
da22c0f359
2 changed files with 6 additions and 4 deletions
|
@ -1,12 +1,10 @@
|
|||
# encoding: utf-8
|
||||
|
||||
# Generates a slug. This is annoying because it's duplicating what the javascript
|
||||
# does, but on the other hand slugs are never matched so it's okay if they differ
|
||||
# a little.
|
||||
module Slug
|
||||
|
||||
def self.for(string)
|
||||
slug = string.parameterize.gsub("_", "-")
|
||||
slug = string.gsub("'", "").parameterize
|
||||
slug.gsub!("_", "-")
|
||||
slug =~ /[^\d]/ ? slug : '' # Reject slugs that only contain numbers, because they would be indistinguishable from id's.
|
||||
end
|
||||
|
||||
|
|
|
@ -51,5 +51,9 @@ describe Slug do
|
|||
Slug.for('電車男 2').should be_blank
|
||||
end
|
||||
|
||||
it "doesn't keep single quotes within word" do
|
||||
Slug.for("Jeff hate's this").should == "jeff-hates-this"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue