mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
18 lines
436 B
Ruby
18 lines
436 B
Ruby
# encoding: utf-8
|
|
|
|
|
|
module Slug
|
|
|
|
def self.for(string)
|
|
slug = string.gsub("'", "").parameterize
|
|
slug.gsub!("_", "-")
|
|
if ['zh_CN', 'ja', 'ko'].include?(SiteSetting.default_locale)
|
|
unless defined? Stringex
|
|
require 'stringex_lite'
|
|
end
|
|
slug = string.to_url
|
|
end
|
|
slug =~ /[^\d]/ ? slug : '' # Reject slugs that only contain numbers, because they would be indistinguishable from id's.
|
|
end
|
|
|
|
end
|