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)
word = camel_cased_word.to_s.gsub("::", "/")
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.downcase!
word

View File

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