From bc7261c667d31b601e4c8384cd8ec479e9822e01 Mon Sep 17 00:00:00 2001 From: William Woodruff Date: Sun, 14 Jul 2024 13:00:30 -0400 Subject: [PATCH] resource_auditor: fix wheel URL audit Signed-off-by: William Woodruff --- Library/Homebrew/resource_auditor.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/resource_auditor.rb b/Library/Homebrew/resource_auditor.rb index 796af321e5..7a208c95da 100644 --- a/Library/Homebrew/resource_auditor.rb +++ b/Library/Homebrew/resource_auditor.rb @@ -108,8 +108,13 @@ module Homebrew return unless url.match?(%r{^https?://files\.pythonhosted\.org/packages/}) return if name == owner.name # Skip the top-level package name as we only care about `resource "foo"` blocks. - url =~ %r{/(?[^/]+)-} - pypi_package_name = Regexp.last_match(:package_name).to_s.gsub(/[_.]/, "-") + if url.end_with? ".whl" + pypi_package_name, = File.basename(URI(url).path).split("-", 2) + else + url =~ %r{/(?[^/]+)-} + pypi_package_name = Regexp.last_match(:package_name).to_s.gsub(/[_.]/, "-") + end + return if name.casecmp(pypi_package_name).zero? problem "resource name should be `#{pypi_package_name}` to match the PyPI package name"