discourse/lib/slug.rb

12 lines
261 B
Ruby
Raw Normal View History

2013-02-06 03:16:51 +08:00
# encoding: utf-8
module Slug
def self.for(string)
2013-06-03 07:08:34 +08:00
slug = string.gsub("'", "").parameterize
slug.gsub!("_", "-")
slug =~ /[^\d]/ ? slug : '' # Reject slugs that only contain numbers, because they would be indistinguishable from id's.
2013-02-06 03:16:51 +08:00
end
end