提交 1ddde913 编写于 作者: M Michael Koziarski

Flesh out the parameterize method to support non-ascii text and underscores.

上级 46bac29d
......@@ -257,7 +257,7 @@ def demodulize(class_name_in_module)
# <%= link_to(@person.name, person_path %>
# # => <a href="/person/1-donald-e-knuth">Donald E. Knuth</a>
def parameterize(string, sep = '-')
string.gsub(/[^a-z0-9]+/i, sep).downcase
string.chars.normalize(:kd).to_s.gsub(/[^\x00-\x7F]+/, '').gsub(/[^a-z0-9_\-]+/i, sep).downcase
end
# Create the name of a table like Rails does for models to table names. This method
......
......@@ -144,7 +144,10 @@ module InflectorTestCases
StringToParameterized = {
"Donald E. Knuth" => "donald-e-knuth",
"Random text with *(bad)* characters" => "random-text-with-bad-characters"
"Random text with *(bad)* characters" => "random-text-with-bad-characters",
"Malmö" => "malmo",
"Garçons" => "garcons",
"Allow_Under_Scores" => "allow_under_scores"
}
UnderscoreToHuman = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册