diff --git a/Library/Homebrew/cask/cask_loader.rb b/Library/Homebrew/cask/cask_loader.rb index cf2ac67abb0241..c4629e8ae446f0 100644 --- a/Library/Homebrew/cask/cask_loader.rb +++ b/Library/Homebrew/cask/cask_loader.rb @@ -232,10 +232,7 @@ class FromDefaultTapLoader < FromTapLoader } def self.try_new(ref, warn: false) ref = ref.to_s - - return unless (match = ref.match(HOMEBREW_DEFAULT_TAP_CASK_REGEX)) - - token = match[:token] + return unless (token = ref[HOMEBREW_DEFAULT_TAP_CASK_REGEX, :token]) ref = "#{CoreCaskTap.instance}/#{token}" diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index 581192362c2cba..c9ebae97130635 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -694,9 +694,7 @@ class FromTapLoader < FormulaLoader } def self.try_new(ref, from: T.unsafe(nil), warn: false) ref = ref.to_s - return unless (match = ref.match(HOMEBREW_TAP_FORMULA_REGEX)) - - alias_name = T.cast(match[:name], String) + return unless (name = alias_name = ref[HOMEBREW_TAP_FORMULA_REGEX, :name]) name, tap, type = Formulary.tap_formula_name_type(ref, warn: warn) path = Formulary.find_formula_in_tap(name, tap) @@ -853,10 +851,8 @@ class FromAPILoader < FormulaLoader def self.try_new(ref, from: T.unsafe(nil), warn: false) return if Homebrew::EnvConfig.no_install_from_api? return unless ref.is_a?(String) + return unless (name = alias_name = ref[HOMEBREW_DEFAULT_TAP_FORMULA_REGEX, :name]) - return unless (match = ref.match(HOMEBREW_DEFAULT_TAP_FORMULA_REGEX)) - - name = alias_name = T.cast(match[:name], String) if !Homebrew::API::Formula.all_formulae.key?(name) && !Homebrew::API::Formula.all_aliases.key?(name) && !Homebrew::API::Formula.all_renames.key?(name)