Support multiple capture groups in PageMatch strategy.

This commit is contained in:
Markus Reiter 2020-12-13 12:24:25 +01:00 committed by Sam Ford
parent df70296403
commit aba4eac8ab
No known key found for this signature in database
GPG Key ID: 95209E46C7FFDEFE

View File

@ -48,7 +48,19 @@ module Homebrew
# @return [Array] # @return [Array]
def self.page_matches(url, regex) def self.page_matches(url, regex)
page = Strategy.page_contents(url) page = Strategy.page_contents(url)
page.scan(regex).map(&:first).uniq
matches = page.scan(regex)
regex_names = regex.names.map(&:to_sym)
if regex_names.count > 1
matches.map do |match|
match_data = regex_names.zip(match).to_h
regex_names.sort.map { |name| match_data[name] }.join(",")
end.uniq
else
matches.map(&:first).uniq
end
end end
# Checks the content at the URL for new versions, using the provided # Checks the content at the URL for new versions, using the provided