fix(cli/fetch): fix relative redirect (#6715)

This commit is contained in:
Marcos Casagrande 2020-07-13 06:53:36 +02:00 committed by GitHub
parent ac000341db
commit 4aeac64ecd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 5 deletions

View file

@ -342,11 +342,7 @@ export async function fetch(
!redirectUrl.startsWith("http://") &&
!redirectUrl.startsWith("https://")
) {
redirectUrl =
url.split("//")[0] +
"//" +
url.split("//")[1].split("/")[0] +
redirectUrl; // TODO: handle relative redirection more gracefully
redirectUrl = new URL(redirectUrl, url).href;
}
url = redirectUrl;
redirected = true;