diff --git a/Casks/cockatrice.rb b/Casks/cockatrice.rb index 455a74ba11..306d3f4552 100644 --- a/Casks/cockatrice.rb +++ b/Casks/cockatrice.rb @@ -23,12 +23,20 @@ cask "cockatrice" do homepage "https://cockatrice.github.io/" livecheck do - url :url - strategy :github_latest do |page| - match = page.match( - %r{href=".*?/(\d+(?:-\d+)+)-Release-(\d+(?:\.\d+)+)/Cockatrice-([^/]+)-\2-macOS-[.\w]*\.dmg"}i, + url "https://github.com/Cockatrice/Cockatrice/releases/latest/" + regex(%r{href=".*?/(\d+(?:-\d+)+)-Release-(\d+(?:\.\d+)+)/Cockatrice-([^/]+)-\2-macOS-[.\w]*\.dmg"}i) + strategy :header_match do |headers, regex| + next if headers["location"].blank? + + # Identify the latest tag from the response's `location` header + latest_tag = File.basename(headers["location"]) + next if latest_tag.blank? + + # Fetch the assets list HTML for the latest tag and match within it + assets_page = Homebrew::Livecheck::Strategy.page_content( + @url.sub(%r{/releases/?.+}, "/releases/expanded_assets/#{latest_tag}"), ) - "#{match[2]},#{match[1]},#{match[3]}" + assets_page[:content]&.scan(regex)&.map { |match| "#{match[1]},#{match[0]},#{match[2]}" } end end