From 68d81fa6330faaf9be24f64a5b17fb2cb4abee6b Mon Sep 17 00:00:00 2001 From: Peter Cooper Jr Date: Wed, 9 Oct 2019 13:13:05 -0400 Subject: [PATCH] fix: Allow following redirects that go to another server --- lib/StringClient.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/StringClient.js b/lib/StringClient.js index 70e2a40..5d438c2 100644 --- a/lib/StringClient.js +++ b/lib/StringClient.js @@ -119,7 +119,11 @@ StringClient.prototype.read = function read(options, callback) { req.once('result', self._onResult(callback)); req.once('redirect', function (res) { res.resume(); - options.path = res.headers.location; + var redirectURL = new URL(res.headers.location); + options.protocol = redirectURL.protocol; + options.hostname = redirectURL.hostname; + options.port = redirectURL.port; + options.path = redirectURL.href; if (res.forceGet) { forceGetOptions(options);