1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix (Inflector::Methods#underscore): small regression

This commit is contained in:
Quentin "Thornolf" Baudet 2021-10-28 00:25:09 +02:00
parent 18922cccd4
commit 86faeb8386
No known key found for this signature in database
GPG key ID: 2DC39A9408EF4ABC
2 changed files with 2 additions and 1 deletions

View file

@ -97,7 +97,7 @@ module ActiveSupport
return camel_cased_word.to_s unless /[A-Z-]|::/.match?(camel_cased_word) return camel_cased_word.to_s unless /[A-Z-]|::/.match?(camel_cased_word)
word = camel_cased_word.to_s.gsub("::", "/") word = camel_cased_word.to_s.gsub("::", "/")
word.gsub!(inflections.acronyms_underscore_regex) { "#{$1 && '_' }#{$2.downcase}" } word.gsub!(inflections.acronyms_underscore_regex) { "#{$1 && '_' }#{$2.downcase}" }
word.gsub!(/([A-Z\d]+)(?=[A-Z][a-z])|([a-z\d])(?=[A-Z])/) { ($1 || $2) << "_" } word.gsub!(/([A-Z]+)(?=[A-Z][a-z])|([a-z\d])(?=[A-Z])/) { ($1 || $2) << "_" }
word.tr!("-", "_") word.tr!("-", "_")
word.downcase! word.downcase!
word word

View file

@ -121,6 +121,7 @@ module InflectorTestCases
"ApplicationController" => "application_controller", "ApplicationController" => "application_controller",
"Area51Controller" => "area51_controller", "Area51Controller" => "area51_controller",
"AppCDir" => "app_c_dir", "AppCDir" => "app_c_dir",
"Accountsv2N2Test" => "accountsv2_n2_test",
} }
UnderscoreToLowerCamel = { UnderscoreToLowerCamel = {