DEV: Prefer \A and \z over ^ and $ in regexes (#19936)

This commit is contained in:
Daniel Waterworth
2023-01-20 12:52:49 -06:00
committed by GitHub
parent f7907a3645
commit 666536cbd1
115 changed files with 294 additions and 291 deletions

View File

@ -39,7 +39,7 @@ module I18n
if @loaded_locales.empty?
# load all rb files
I18n.backend.load_translations(I18n.load_path.grep(/\.rb$/))
I18n.backend.load_translations(I18n.load_path.grep(/\.rb\z/))
# load plural rules from plugins
DiscoursePluginRegistry.locales.each do |plugin_locale, options|
@ -50,14 +50,14 @@ module I18n
end
# load it
I18n.backend.load_translations(I18n.load_path.grep(/\.#{Regexp.escape locale}\.yml$/))
I18n.backend.load_translations(I18n.load_path.grep(/\.#{Regexp.escape locale}\.yml\z/))
if Discourse.allow_dev_populate?
I18n.backend.load_translations(
I18n.load_path.grep(%r{.*faker.*/#{Regexp.escape locale}\.yml$}),
I18n.load_path.grep(%r{.*faker.*/#{Regexp.escape locale}\.yml\z}),
)
I18n.backend.load_translations(
I18n.load_path.grep(%r{.*faker.*/#{Regexp.escape locale}/.*\.yml$}),
I18n.load_path.grep(%r{.*faker.*/#{Regexp.escape locale}/.*\.yml\z}),
)
end