diff --git a/index.js b/index.js index 52c7d99..fb76e55 100644 --- a/index.js +++ b/index.js @@ -367,14 +367,7 @@ RedirectableRequest.prototype._processResponse = function (response) { // If the redirect is relative, carry over the host of the last request from host header var previousHostUrl = !url.parse(location).host ? - url.format({ - protocol: currentUrlParts.protocol, - auth: currentUrlParts.auth, - host: previousHost, - pathname: currentUrlParts.pathname, - search: currentUrlParts.search, - hash: currentUrlParts.hash, - }) : + url.format(Object.assign({}, currentUrlParts, { host: previousHost })) : this._currentUrl; // Create the redirected request