mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 15:48:43 -05:00
11 lines
261 B
Ruby
11 lines
261 B
Ruby
# encoding: utf-8
|
|
|
|
module Slug
|
|
|
|
def self.for(string)
|
|
slug = string.gsub("'", "").parameterize
|
|
slug.gsub!("_", "-")
|
|
slug =~ /[^\d]/ ? slug : '' # Reject slugs that only contain numbers, because they would be indistinguishable from id's.
|
|
end
|
|
|
|
end
|