diff --git a/Library/Homebrew/cask/audit.rb b/Library/Homebrew/cask/audit.rb index b095905211..e71c4d97a5 100644 --- a/Library/Homebrew/cask/audit.rb +++ b/Library/Homebrew/cask/audit.rb @@ -259,7 +259,7 @@ module Cask bad_url_format?(/sourceforge/, [ %r{\Ahttps://sourceforge\.net/projects/[^/]+/files/latest/download\Z}, - %r{\Ahttps://downloads\.sourceforge\.net/(?!(project|sourceforge)\/)}, + %r{\Ahttps://downloads\.sourceforge\.net/(?!(project|sourceforge)/)}, ]) end diff --git a/Library/Homebrew/cask/blacklist.rb b/Library/Homebrew/cask/blacklist.rb index c37ac82fef..810067a39e 100644 --- a/Library/Homebrew/cask/blacklist.rb +++ b/Library/Homebrew/cask/blacklist.rb @@ -4,7 +4,7 @@ module Cask module Blacklist def self.blacklisted_reason(name) case name - when /^adobe\-(after|illustrator|indesign|photoshop|premiere)/ + when /^adobe-(after|illustrator|indesign|photoshop|premiere)/ "Adobe casks were removed because they are too difficult to maintain." when /^audacity$/ "Audacity was removed because it is too difficult to download programmatically." diff --git a/Library/Homebrew/cask/cmd.rb b/Library/Homebrew/cask/cmd.rb index ce0562d87c..139e063887 100644 --- a/Library/Homebrew/cask/cmd.rb +++ b/Library/Homebrew/cask/cmd.rb @@ -180,7 +180,7 @@ module Cask end def process_options(*args) - exclude_regex = /^\-\-#{Regexp.union(*Config::DEFAULT_DIRS.keys.map(&Regexp.public_method(:escape)))}=/ + exclude_regex = /^--#{Regexp.union(*Config::DEFAULT_DIRS.keys.map(&Regexp.public_method(:escape)))}=/ non_options = [] diff --git a/Library/Homebrew/cask/cmd/options.rb b/Library/Homebrew/cask/cmd/options.rb index 9dca4e3d7f..c6bb427892 100644 --- a/Library/Homebrew/cask/cmd/options.rb +++ b/Library/Homebrew/cask/cmd/options.rb @@ -46,7 +46,7 @@ module Cask next if self.class.options.nil? self.class.options.each do |option_name, option_method| - option_type = case option_name.split(/(\ |\=)/).last + option_type = case option_name.split(/(\ |=)/).last when "PATH" Pathname when /\w+(,\w+)+/ diff --git a/Library/Homebrew/cask/config.rb b/Library/Homebrew/cask/config.rb index a415b74d78..bd9bd71155 100644 --- a/Library/Homebrew/cask/config.rb +++ b/Library/Homebrew/cask/config.rb @@ -86,7 +86,7 @@ module Cask Shellwords.shellsplit(ENV.fetch("HOMEBREW_CASK_OPTS", "")) .select { |arg| arg.include?("=") } .map { |arg| arg.split("=", 2) } - .map { |(flag, value)| [flag.sub(/^\-\-/, ""), value] }, + .map { |(flag, value)| [flag.sub(/^--/, ""), value] }, ) end diff --git a/Library/Homebrew/cask/dsl/version.rb b/Library/Homebrew/cask/dsl/version.rb index 477360047e..fd8328ad06 100644 --- a/Library/Homebrew/cask/dsl/version.rb +++ b/Library/Homebrew/cask/dsl/version.rb @@ -11,9 +11,9 @@ module Cask DIVIDER_REGEX = /(#{DIVIDERS.keys.map { |v| Regexp.quote(v) }.join('|')})/.freeze - MAJOR_MINOR_PATCH_REGEX = /^([^.,:]+)(?:\.([^.,:]+)(?:\.([^.,:]+))?)?/.freeze + MAJOR_MINOR_PATCH_REGEX = /^([^.,:]+)(?:.([^.,:]+)(?:.([^.,:]+))?)?/.freeze - INVALID_CHARACTERS = /[^0-9a-zA-Z\.\,\:\-\_]/.freeze + INVALID_CHARACTERS = /[^0-9a-zA-Z.,:\-_]/.freeze class << self private @@ -75,7 +75,7 @@ module Cask s = downcase.delete(".").gsub(/[^a-z\d]+/, "-") return true if s.match?(/(\d+|\b)(alpha|beta|preview|rc|dev|canary|snapshot)(\d+|\b)/i) - return true if s.match?(/\A[a-z\d]+(\-\d+)*\-?(a|b|pre)(\d+|\b)/i) + return true if s.match?(/\A[a-z\d]+(-\d+)*-?(a|b|pre)(\d+|\b)/i) false end diff --git a/Library/Homebrew/cleanup.rb b/Library/Homebrew/cleanup.rb index 3003de496b..c2b53660fc 100644 --- a/Library/Homebrew/cleanup.rb +++ b/Library/Homebrew/cleanup.rb @@ -56,14 +56,14 @@ module CleanupRefinement end end - version ||= basename.to_s[/\A.*(?:\-\-.*?)*\-\-(.*?)#{Regexp.escape(extname)}\Z/, 1] - version ||= basename.to_s[/\A.*\-\-?(.*?)#{Regexp.escape(extname)}\Z/, 1] + version ||= basename.to_s[/\A.*(?:--.*?)*--(.*?)#{Regexp.escape(extname)}\Z/, 1] + version ||= basename.to_s[/\A.*--?(.*?)#{Regexp.escape(extname)}\Z/, 1] return false unless version version = Version.new(version) - return false unless formula_name = basename.to_s[/\A(.*?)(?:\-\-.*?)*\-\-?(?:#{Regexp.escape(version)})/, 1] + return false unless formula_name = basename.to_s[/\A(.*?)(?:--.*?)*--?(?:#{Regexp.escape(version)})/, 1] formula = begin Formulary.from_rack(HOMEBREW_CELLAR/formula_name) @@ -71,7 +71,7 @@ module CleanupRefinement return false end - resource_name = basename.to_s[/\A.*?\-\-(.*?)\-\-?(?:#{Regexp.escape(version)})/, 1] + resource_name = basename.to_s[/\A.*?--(.*?)--?(?:#{Regexp.escape(version)})/, 1] if resource_name == "patch" patch_hashes = formula.stable&.patches&.select(&:external?)&.map(&:resource)&.map(&:version) @@ -92,7 +92,7 @@ module CleanupRefinement end def stale_cask?(scrub) - return false unless name = basename.to_s[/\A(.*?)\-\-/, 1] + return false unless name = basename.to_s[/\A(.*?)--/, 1] cask = begin Cask::CaskLoader.load(name) @@ -100,7 +100,7 @@ module CleanupRefinement return false end - return true unless basename.to_s.match?(/\A#{Regexp.escape(name)}\-\-#{Regexp.escape(cask.version)}\b/) + return true unless basename.to_s.match?(/\A#{Regexp.escape(name)}--#{Regexp.escape(cask.version)}\b/) return true if scrub && !cask.versions.include?(cask.version) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index a35795044e..b9108f3e08 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -669,7 +669,7 @@ module Homebrew .map(&:to_i) case (url = stable.url) - when /[\d\._-](alpha|beta|rc\d)/ + when /[\d._-](alpha|beta|rc\d)/ matched = Regexp.last_match(1) version_prefix = stable_version_string.sub(/\d+$/, "") return if UNSTABLE_WHITELIST[formula.name] == version_prefix @@ -803,7 +803,7 @@ module Homebrew end bin_names.each do |name| ["system", "shell_output", "pipe_output"].each do |cmd| - if text.to_s.match?(/test do.*#{cmd}[\(\s]+['"]#{Regexp.escape(name)}[\s'"]/m) + if text.to_s.match?(/test do.*#{cmd}[(\s]+['"]#{Regexp.escape(name)}[\s'"]/m) problem %Q(fully scope test #{cmd} calls, e.g. #{cmd} "\#{bin}/#{name}") end end diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index a296594097..20fc41ed2a 100644 --- a/Library/Homebrew/dev-cmd/bottle.rb +++ b/Library/Homebrew/dev-cmd/bottle.rb @@ -321,7 +321,7 @@ module Homebrew if any_go_deps go_regex = Version.formula_optionally_versioned_regex(:go, full: false) - ignores << %r{#{Regexp.escape(HOMEBREW_CELLAR)}/#{go_regex}/[\d\.]+/libexec} + ignores << %r{#{Regexp.escape(HOMEBREW_CELLAR)}/#{go_regex}/[\d.]+/libexec} end relocatable = true diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index 77b64f8832..c3426f0ae3 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -79,7 +79,7 @@ module Homebrew origin_branch = "#{homebrew_core_remote}/#{homebrew_core_branch}" previous_branch = Utils.popen_read("git -C \"#{formula.tap.path}\" symbolic-ref -q --short HEAD").chomp previous_branch = "master" if previous_branch.empty? - formula_path = formula.path.to_s[%r{(Formula\/.*)}, 1] + formula_path = formula.path.to_s[%r{(Formula/.*)}, 1] if args.dry_run? ohai "git remote add #{homebrew_core_remote} #{homebrew_core_url}" @@ -89,7 +89,7 @@ module Homebrew return tap_full_name, origin_branch, previous_branch else formula.path.parent.cd do - unless Utils.popen_read("git remote -v").match?(%r{^homebrew.*Homebrew\/homebrew-core.*$}) + unless Utils.popen_read("git remote -v").match?(%r{^homebrew.*Homebrew/homebrew-core.*$}) ohai "Adding #{homebrew_core_remote} remote" safe_system "git", "remote", "add", homebrew_core_remote, homebrew_core_url end @@ -225,7 +225,7 @@ module Homebrew replacement_pairs += formula_spec.mirrors.map do |mirror| [ - / +mirror \"#{Regexp.escape(mirror)}\"\n/m, + / +mirror "#{Regexp.escape(mirror)}"\n/m, "", ] end @@ -258,7 +258,7 @@ module Homebrew if new_mirrors replacement_pairs << [ - /^( +)(url \"#{Regexp.escape(new_url)}\"\n)/m, + /^( +)(url "#{Regexp.escape(new_url)}"\n)/m, "\\1\\2\\1mirror \"#{new_mirrors.join("\"\n\\1mirror \"")}\"\n", ] end @@ -283,30 +283,30 @@ module Homebrew ] elsif new_mirrors [ - /^( +)(mirror \"#{Regexp.escape(new_mirrors.last)}\"\n)/m, + /^( +)(mirror "#{Regexp.escape(new_mirrors.last)}"\n)/m, "\\1\\2\\1version \"#{forced_version}\"\n", ] else [ - /^( +)(url \"#{Regexp.escape(new_url)}\"\n)/m, + /^( +)(url "#{Regexp.escape(new_url)}"\n)/m, "\\1\\2\\1version \"#{forced_version}\"\n", ] end elsif requested_spec == :devel replacement_pairs << [ - /( devel do.+?version \")#{old_formula_version}(\"\n.+?end\n)/m, + /( devel do.+?version ")#{old_formula_version}("\n.+?end\n)/m, "\\1#{forced_version}\\2", ] end elsif forced_version && forced_version == "0" if requested_spec == :stable replacement_pairs << [ - /^ version \"[\w\.\-\+]+\"\n/m, + /^ version "[\w.\-+]+"\n/m, "", ] elsif requested_spec == :devel replacement_pairs << [ - /( devel do.+?)^ +version \"[^\n]+\"\n(.+?end\n)/m, + /( devel do.+?)^ +version "[^\n]+"\n(.+?end\n)/m, "\\1\\2", ] end diff --git a/Library/Homebrew/dev-cmd/pull.rb b/Library/Homebrew/dev-cmd/pull.rb index 5950f72bea..d15312a901 100644 --- a/Library/Homebrew/dev-cmd/pull.rb +++ b/Library/Homebrew/dev-cmd/pull.rb @@ -333,7 +333,7 @@ module Homebrew def check_bintray_mirror(name, url) headers, = curl_output("--connect-timeout", "15", "--location", "--head", url) - status_code = headers.scan(%r{^HTTP\/.* (\d+)}).last.first + status_code = headers.scan(%r{^HTTP/.* (\d+)}).last.first return if status_code.start_with?("2") opoo "The Bintray mirror #{url} is not reachable (HTTP status code #{status_code})." diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 3d8ca97571..e98b300828 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -221,7 +221,7 @@ class AbstractFileDownloadStrategy < AbstractDownloadStrategy end def basename - cached_location.basename.sub(/^[\da-f]{64}\-\-/, "") + cached_location.basename.sub(/^[\da-f]{64}--/, "") end private @@ -390,7 +390,7 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy filenames = lines.map(&parse_content_disposition).compact time = - lines.map { |line| line[/^Last\-Modified:\s*(.+)/i, 1] } + lines.map { |line| line[/^Last-Modified:\s*(.+)/i, 1] } .compact .map { |t| t.match?(/^\d+$/) ? Time.at(t.to_i) : Time.parse(t) } .last @@ -820,7 +820,7 @@ class GitHubGitDownloadStrategy < GitDownloadStrategy return unless status.success? - commit = output[/^ETag: \"(\h+)\"/, 1] + commit = output[/^ETag: "(\h+)"/, 1] version.update_commit(commit) if commit commit end diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index 2837ff096e..e0c331f4dd 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -224,7 +224,7 @@ class Pathname return archive_ext if archive_ext # Don't treat version numbers as extname. - return "" if basename.match?(/\b\d+\.\d+[^\.]*\Z/) && !basename.end_with?(".7z") + return "" if basename.match?(/\b\d+\.\d+[^.]*\Z/) && !basename.end_with?(".7z") File.extname(basename) end diff --git a/Library/Homebrew/extend/string.rb b/Library/Homebrew/extend/string.rb index 8219024021..903168af60 100644 --- a/Library/Homebrew/extend/string.rb +++ b/Library/Homebrew/extend/string.rb @@ -26,7 +26,7 @@ module StringInreplaceExtension # Looks for Makefile style variable definitions and replaces the # value with "new_value", or removes the definition entirely. def change_make_var!(flag, new_value) - return if gsub!(/^#{Regexp.escape(flag)}[ \t]*[\\?\+\:\!]?=[ \t]*((?:.*\\\n)*.*)$/, "#{flag}=#{new_value}", false) + return if gsub!(/^#{Regexp.escape(flag)}[ \t]*[\\?+:!]?=[ \t]*((?:.*\\\n)*.*)$/, "#{flag}=#{new_value}", false) errors << "expected to change #{flag.inspect} to #{new_value.inspect}" end @@ -35,7 +35,7 @@ module StringInreplaceExtension def remove_make_var!(flags) Array(flags).each do |flag| # Also remove trailing \n, if present. - unless gsub!(/^#{Regexp.escape(flag)}[ \t]*[\\?\+\:\!]?=(?:.*\\\n)*.*$\n?/, "", false) + unless gsub!(/^#{Regexp.escape(flag)}[ \t]*[\\?+:!]?=(?:.*\\\n)*.*$\n?/, "", false) errors << "expected to remove #{flag.inspect}" end end @@ -43,6 +43,6 @@ module StringInreplaceExtension # Finds the specified variable def get_make_var(flag) - self[/^#{Regexp.escape(flag)}[ \t]*[\\?\+\:\!]?=[ \t]*((?:.*\\\n)*.*)$/, 1] + self[/^#{Regexp.escape(flag)}[ \t]*[\\?+:!]?=[ \t]*((?:.*\\\n)*.*)$/, 1] end end diff --git a/Library/Homebrew/locale.rb b/Library/Homebrew/locale.rb index c005e5296d..174c594ad9 100644 --- a/Library/Homebrew/locale.rb +++ b/Library/Homebrew/locale.rb @@ -8,7 +8,7 @@ class Locale REGION_REGEX = /(?:[A-Z]{2}|\d{3})/.freeze # ISO 3166-1 or UN M.49 SCRIPT_REGEX = /(?:[A-Z][a-z]{3})/.freeze # ISO 15924 - LOCALE_REGEX = /\A((?:#{LANGUAGE_REGEX}|#{REGION_REGEX}|#{SCRIPT_REGEX})(?:\-|$)){1,3}\Z/.freeze + LOCALE_REGEX = /\A((?:#{LANGUAGE_REGEX}|#{REGION_REGEX}|#{SCRIPT_REGEX})(?:-|$)){1,3}\Z/.freeze def self.parse(string) string = string.to_s @@ -16,7 +16,7 @@ class Locale raise ParserError, "'#{string}' cannot be parsed to a #{self}" unless string.match?(LOCALE_REGEX) scan = proc do |regex| - string.scan(/(?:\-|^)(#{regex})(?:\-|$)/).flatten.first + string.scan(/(?:-|^)(#{regex})(?:-|$)/).flatten.first end language = scan.call(LANGUAGE_REGEX) diff --git a/Library/Homebrew/rubocops/cask/homepage_matches_url.rb b/Library/Homebrew/rubocops/cask/homepage_matches_url.rb index b260d5c730..d142ad7170 100644 --- a/Library/Homebrew/rubocops/cask/homepage_matches_url.rb +++ b/Library/Homebrew/rubocops/cask/homepage_matches_url.rb @@ -129,7 +129,7 @@ module RuboCop string = stanza.stanza_node.children[2] return string.str_content if string.str_type? - string.to_s.gsub(%r{.*"([a-z0-9]+\:\/\/[^"]+)".*}m, '\1') + string.to_s.gsub(%r{.*"([a-z0-9]+://[^"]+)".*}m, '\1') end def url_match_homepage?(stanza) diff --git a/Library/Homebrew/rubocops/lines.rb b/Library/Homebrew/rubocops/lines.rb index 5ed08a2e03..7de4690695 100644 --- a/Library/Homebrew/rubocops/lines.rb +++ b/Library/Homebrew/rubocops/lines.rb @@ -153,7 +153,7 @@ module RuboCop find_instance_method_call(body_node, :build, :include?) do |method| arg = parameters(method).first - next unless match = regex_match_group(arg, /^\-\-(.*)$/) + next unless match = regex_match_group(arg, /^--(.*)$/) problem "Reference '#{match[1]}' without dashes" end @@ -403,7 +403,7 @@ module RuboCop path = parameters(method).first next unless path.str_type? - next unless match = regex_match_group(path, /^[^\*{},]+$/) + next unless match = regex_match_group(path, /^[^*{},]+$/) problem "Dir([\"#{string_content(path)}\"]) is unnecessary; just use \"#{match[0]}\"" end diff --git a/Library/Homebrew/system_config.rb b/Library/Homebrew/system_config.rb index def1702154..75fff1db24 100644 --- a/Library/Homebrew/system_config.rb +++ b/Library/Homebrew/system_config.rb @@ -88,7 +88,7 @@ class SystemConfig _, err, status = system_command("java", args: ["-version"], print_stderr: false) return "N/A" unless status.success? - err[/java version "([\d\._]+)"/, 1] || "N/A" + err[/java version "([\d._]+)"/, 1] || "N/A" end def describe_git @@ -100,7 +100,7 @@ class SystemConfig def describe_curl out, = system_command(curl_executable, args: ["--version"]) - if /^curl (?[\d\.]+)/ =~ out + if /^curl (?[\d.]+)/ =~ out "#{curl_version} => #{curl_executable}" else "N/A" diff --git a/Library/Homebrew/test/cmd/--cache_spec.rb b/Library/Homebrew/test/cmd/--cache_spec.rb index d682565306..42b452ec60 100644 --- a/Library/Homebrew/test/cmd/--cache_spec.rb +++ b/Library/Homebrew/test/cmd/--cache_spec.rb @@ -9,7 +9,7 @@ end describe "brew --cache", :integration_test do it "prints all cache files for a given Formula" do expect { brew "--cache", testball } - .to output(%r{#{HOMEBREW_CACHE}/downloads/[\da-f]{64}\-\-testball\-}).to_stdout + .to output(%r{#{HOMEBREW_CACHE}/downloads/[\da-f]{64}--testball-}).to_stdout .and not_to_output.to_stderr .and be_a_success end diff --git a/Library/Homebrew/test/cmd/install_spec.rb b/Library/Homebrew/test/cmd/install_spec.rb index b0623567a3..70ba941c78 100644 --- a/Library/Homebrew/test/cmd/install_spec.rb +++ b/Library/Homebrew/test/cmd/install_spec.rb @@ -68,7 +68,7 @@ describe "brew install", :integration_test do # and there will be the git requirement, but we cannot instantiate git # formula since we only have testball1 formula. expect { brew "install", "testball1", "--HEAD", "--ignore-dependencies" } - .to output(%r{#{HOMEBREW_CELLAR}/testball1/HEAD\-d5eb689}).to_stdout + .to output(%r{#{HOMEBREW_CELLAR}/testball1/HEAD-d5eb689}).to_stdout .and output(/Cloning into/).to_stderr .and be_a_success expect(HOMEBREW_CELLAR/"testball1/HEAD-d5eb689/foo/test").not_to be_a_file diff --git a/Library/Homebrew/test/rubocops/homepage_spec.rb b/Library/Homebrew/test/rubocops/homepage_spec.rb index cfeff7f5bb..033cd0a0bb 100644 --- a/Library/Homebrew/test/rubocops/homepage_spec.rb +++ b/Library/Homebrew/test/rubocops/homepage_spec.rb @@ -73,7 +73,7 @@ describe RuboCop::Cop::FormulaAudit::Homepage do RUBY inspect_source(source) - if homepage.match?(%r{http:\/\/www\.freedesktop\.org}) + if homepage.match?(%r{http://www\.freedesktop\.org}) if homepage.match?(/Software/) expected_offenses = [{ message: "#{homepage} should be styled " \ "`https://wiki.freedesktop.org/www/Software/project_name`", @@ -89,7 +89,7 @@ describe RuboCop::Cop::FormulaAudit::Homepage do column: 2, source: source }] end - elsif homepage.match?(%r{https:\/\/code\.google\.com}) + elsif homepage.match?(%r{https://code\.google\.com}) expected_offenses = [{ message: "#{homepage} should end with a slash", severity: :convention, line: 2, diff --git a/Library/Homebrew/test/searchable_spec.rb b/Library/Homebrew/test/searchable_spec.rb index aaf88c2eaf..6fdb4557d7 100644 --- a/Library/Homebrew/test/searchable_spec.rb +++ b/Library/Homebrew/test/searchable_spec.rb @@ -19,7 +19,7 @@ describe Searchable do context "when given a regex" do it "does not simplify strings" do - expect(subject.search(/with\-dashes/)).to eq ["with-dashes"] + expect(subject.search(/with-dashes/)).to eq ["with-dashes"] end end diff --git a/Library/Homebrew/test/utils_spec.rb b/Library/Homebrew/test/utils_spec.rb index d27290ef47..977852b6b2 100644 --- a/Library/Homebrew/test/utils_spec.rb +++ b/Library/Homebrew/test/utils_spec.rb @@ -253,7 +253,7 @@ describe "globally-scoped helper methods" do ) }.to raise_error( MethodDeprecatedError, - %r{method.*replacement.*homebrew/core.*\/Taps\/homebrew\/homebrew-core\/}m, + %r{method.*replacement.*homebrew/core.*/Taps/homebrew/homebrew-core/}m, ) end end diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 4f099ceada..3ddf50c79c 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -168,7 +168,7 @@ module Kernel tap = Tap.fetch(match[:user], match[:repo]) tap_message = +"\nPlease report this issue to the #{tap} tap (not Homebrew/brew or Homebrew/core)" tap_message += ", or even better, submit a PR to fix it" if replacement - tap_message << ":\n #{line.sub(/^(.*\:\d+)\:.*$/, '\1')}\n\n" + tap_message << ":\n #{line.sub(/^(.*:\d+):.*$/, '\1')}\n\n" break end diff --git a/Library/Homebrew/utils/curl.rb b/Library/Homebrew/utils/curl.rb index 25d5e2235b..7503e16822 100644 --- a/Library/Homebrew/utils/curl.rb +++ b/Library/Homebrew/utils/curl.rb @@ -196,7 +196,7 @@ def curl_http_content_headers_and_checksum(url, hash_needed: false, user_agent: status_code = :unknown while status_code == :unknown || status_code.to_s.start_with?("3") headers, _, output = output.partition("\r\n\r\n") - status_code = headers[%r{HTTP\/.* (\d+)}, 1] + status_code = headers[%r{HTTP/.* (\d+)}, 1] final_url = headers[/^Location:\s*(.*)$/i, 1]&.chomp end @@ -208,7 +208,7 @@ def curl_http_content_headers_and_checksum(url, hash_needed: false, user_agent: url: url, final_url: final_url, status: status_code, - etag: headers[%r{ETag: ([wW]\/)?"(([^"]|\\")*)"}, 2], + etag: headers[%r{ETag: ([wW]/)?"(([^"]|\\")*)"}, 2], content_length: headers[/Content-Length: (\d+)/, 1], file_hash: output_hash, file: output,