Skip to content

Commit

Permalink
Fixed port on redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
Giotino committed Sep 5, 2020
1 parent d12d6af commit dfe8c41
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion source/core/index.ts
Expand Up @@ -2068,7 +2068,7 @@ export default class Request extends Duplex implements RequestEvents<Request> {
decodeURI(redirectString);

// Redirecting to a different site, clear sensitive data.
if (redirectUrl.hostname !== url.hostname) {
if (redirectUrl.hostname !== url.hostname || redirectUrl.port !== url.port) {
if ('host' in options.headers) {
delete options.headers.host;
}
Expand All @@ -2088,6 +2088,10 @@ export default class Request extends Duplex implements RequestEvents<Request> {
// @ts-expect-error
delete options.password;
}

if ('port' in options) {
delete options.port;
}
}

this.redirects.push(redirectString);
Expand Down

0 comments on commit dfe8c41

Please sign in to comment.