Skip to content

Commit

Permalink
download_strategy: ignore query strings when parsing resolved URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo98 committed Apr 11, 2022
1 parent 3acdab2 commit a50db13
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Library/Homebrew/download_strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def resolved_url_and_basename
@resolved_url_and_basename = [url, parse_basename(url)]
end

def parse_basename(url)
def parse_basename(url, search_query: true)
uri_path = if url.match?(URI::DEFAULT_PARSER.make_regexp)
uri = URI(url)

Expand All @@ -339,7 +339,11 @@ def parse_basename(url)
end
end

uri.query ? "#{uri.path}?#{uri.query}" : uri.path
if uri.query && search_query
"#{uri.path}?#{uri.query}"
else
uri.path
end
else
url
end
Expand Down Expand Up @@ -509,8 +513,8 @@ def resolve_url_basename_time_file_size(url, timeout: nil)
.map(&:to_i)
.last

basename = filenames.last || parse_basename(redirect_url)
is_redirection = url != redirect_url
basename = filenames.last || parse_basename(redirect_url, search_query: !is_redirection)

@resolved_info_cache[url] = [redirect_url, basename, time, file_size, is_redirection]
end
Expand Down

0 comments on commit a50db13

Please sign in to comment.