From bf163013d92c75703cb4bc508da5b8c83365402c Mon Sep 17 00:00:00 2001 From: Issy Long Date: Tue, 12 Sep 2023 00:30:21 +0100 Subject: [PATCH] Use a regex instead of splitting the URL on `/` etc --- Library/Homebrew/resource_auditor.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/resource_auditor.rb b/Library/Homebrew/resource_auditor.rb index 1f9b1c5a13..acfa38fc2a 100644 --- a/Library/Homebrew/resource_auditor.rb +++ b/Library/Homebrew/resource_auditor.rb @@ -104,7 +104,8 @@ 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. - pypi_package_name = url.split("/").last.split(/[-.]\d+?./).first.gsub(/[_.]/, "-") + url =~ %r{/(?[^/]+)-} + pypi_package_name = Regexp.last_match(:package_name).gsub(/[_.]/, "-") return if name.casecmp(pypi_package_name).zero? problem "resource name should be `#{pypi_package_name}` to match the PyPI package name"