diff --git a/Library/Homebrew/livecheck/livecheck.rb b/Library/Homebrew/livecheck/livecheck.rb index b2b1f03570..bccbf45c51 100644 --- a/Library/Homebrew/livecheck/livecheck.rb +++ b/Library/Homebrew/livecheck/livecheck.rb @@ -626,13 +626,10 @@ module Homebrew end if livecheck_strategy.present? - if livecheck_strategy == :page_match && (livecheck_regex.blank? && livecheck_strategy_block.blank?) - odebug "#{strategy_name} strategy requires a regex or block" - next - elsif livecheck_url.blank? + if livecheck_url.blank? odebug "#{strategy_name} strategy requires a URL" next - elsif strategies.exclude?(strategy) + elsif livecheck_strategy != :page_match && strategies.exclude?(strategy) odebug "#{strategy_name} strategy does not apply to this URL" next end diff --git a/Library/Homebrew/livecheck/strategy/page_match.rb b/Library/Homebrew/livecheck/strategy/page_match.rb index d4f57d6b0a..7ef3735636 100644 --- a/Library/Homebrew/livecheck/strategy/page_match.rb +++ b/Library/Homebrew/livecheck/strategy/page_match.rb @@ -90,6 +90,10 @@ module Homebrew ).returns(T::Hash[Symbol, T.untyped]) } def self.find_versions(url:, regex: nil, provided_content: nil, **_unused, &block) + if regex.blank? && block.blank? + raise ArgumentError, "#{T.must(name).demodulize} requires a regex or `strategy` block" + end + match_data = { matches: {}, regex: regex, url: url } return match_data if url.blank? || (regex.blank? && block.blank?)