Skip to content

Commit

Permalink
Merge 10780c1 into adfc6d1
Browse files Browse the repository at this point in the history
  • Loading branch information
tommytroylin committed Nov 4, 2016
2 parents adfc6d1 + 10780c1 commit 0239a35
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ function requestAsEventEmitter(opts) {
ee.emit('error', new got.MaxRedirectsError(statusCode, opts), null, res);
return;
}

redirectUrl = urlLib.resolve(urlLib.format(opts), Buffer.from(res.headers.location, 'binary').toString());
const isNode4 = process.version ? process.version.indexOf('v4.') === 0 : true;
const bufferString = isNode4 ? new Buffer(res.headers.location, 'binary').toString() : Buffer.from(res.headers.location, 'binary').toString();
redirectUrl = urlLib.resolve(urlLib.format(opts), bufferString);
const redirectOpts = Object.assign({}, opts, urlLib.parse(redirectUrl));

ee.emit('redirect', res, redirectOpts);
Expand Down

0 comments on commit 0239a35

Please sign in to comment.