Merge pull request #5053 from vszakats/protrelredir

download_strategy: Miscalculated redirect when `Location:` is protocol-relative
This commit is contained in:
Markus Reiter 2018-10-07 19:09:36 +02:00 committed by GitHub
commit 8b9c80795d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -336,7 +336,10 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy
.compact
redirect_url = locations.reduce(url) do |current_url, location|
if location.start_with?("/")
if location.start_with?("//")
uri = URI(current_url)
"#{uri.scheme}:#{location}"
elsif location.start_with?("/")
uri = URI(current_url)
"#{uri.scheme}://#{uri.host}#{location}"
else