diff --git a/Library/Homebrew/rubocops/urls.rb b/Library/Homebrew/rubocops/urls.rb index af8d299901..1391ae95b3 100644 --- a/Library/Homebrew/rubocops/urls.rb +++ b/Library/Homebrew/rubocops/urls.rb @@ -41,6 +41,11 @@ module RuboCop problem "Please don't use fossies.org in the url (using as a mirror is fine)" end + apache_pattern = %r{^https?://(?:[^/]*\.)?apache\.org/(?:dyn/closer\.cgi\?path=/?|dist/)(.*)}i + audit_urls(urls, apache_pattern) do |match, url| + problem "#{url} should be `https://www.apache.org/dyn/closer.lua?path=#{match[1]}`" + end + audit_urls(mirrors, /.*/) do |_, mirror| urls.each do |url| url_string = string_content(parameters(url).first) @@ -58,7 +63,7 @@ module RuboCop %r{^http://ftpmirror\.gnu\.org/}, %r{^http://download\.savannah\.gnu\.org/}, %r{^http://download-mirror\.savannah\.gnu\.org/}, - %r{^http://[^/]*\.apache\.org/}, + %r{^http://(?:[^/]*\.)?apache\.org/}, %r{^http://code\.google\.com/}, %r{^http://fossies\.org/}, %r{^http://mirrors\.kernel\.org/}, @@ -78,6 +83,11 @@ module RuboCop problem "Please use https:// for #{url}" end + apache_mirror_pattern = %r{^https?://(?:[^/]*\.)?apache\.org/dyn/closer\.(?:cgi|lua)\?path=/?(.*)}i + audit_urls(mirrors, apache_mirror_pattern) do |match, mirror| + problem "Please use `https://archive.apache.org/dist/#{match[1]}` as a mirror instead of #{mirror}." + end + cpan_pattern = %r{^http://search\.mcpan\.org/CPAN/(.*)}i audit_urls(urls, cpan_pattern) do |match, url| problem "#{url} should be `https://cpan.metacpan.org/#{match[1]}`" diff --git a/Library/Homebrew/test/rubocops/urls_spec.rb b/Library/Homebrew/test/rubocops/urls_spec.rb index abedeeaa37..c82bdd3a33 100644 --- a/Library/Homebrew/test/rubocops/urls_spec.rb +++ b/Library/Homebrew/test/rubocops/urls_spec.rb @@ -18,6 +18,11 @@ describe RuboCop::Cop::FormulaAudit::Urls do "url" => "http://tools.ietf.org/tools/rfcmarkup/rfcmarkup-1.119.tgz", "msg" => "Please use https:// for http://tools.ietf.org/tools/rfcmarkup/rfcmarkup-1.119.tgz", "col" => 2, + }, { + "url" => "https://apache.org/dyn/closer.cgi?path=/apr/apr-1.7.0.tar.bz2", + "msg" => "https://apache.org/dyn/closer.cgi?path=/apr/apr-1.7.0.tar.bz2 should be " \ + "`https://www.apache.org/dyn/closer.lua?path=apr/apr-1.7.0.tar.bz2`", + "col" => 2, }, { "url" => "http://search.mcpan.org/CPAN/authors/id/Z/ZE/ZEFRAM/Perl4-CoreLibs-0.003.tar.gz", "msg" => "http://search.mcpan.org/CPAN/authors/id/Z/ZE/ZEFRAM/Perl4-CoreLibs-0.003.tar.gz should be " \