This repository has been archived on 2025-05-04. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
discourse/lib/slug.rb
2013-06-03 09:08:34 +10:00

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