From fdb61db6e0a8e443565b2cdbb5b6f5c580beb9b9 Mon Sep 17 00:00:00 2001 From: John Porter Simons Date: Tue, 6 Mar 2018 09:59:08 -0800 Subject: [PATCH] Allow :// to occur in the path even when baseUrl is used, as long as its not at the beginning Cherry-pick 66017431c1b46c0313ec86b339f5d5b3e327893e --- request.js | 2 +- tests/test-baseUrl.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/request.js b/request.js index e1679f0a1..e15028809 100644 --- a/request.js +++ b/request.js @@ -333,7 +333,7 @@ Request.prototype.init = function (options) { return self.emit('error', new Error('options.uri must be a string when using options.baseUrl')) } - if (self.uri.indexOf('//') === 0 || self.uri.indexOf('://') !== -1) { + if (self.uri.indexOf('//') === 0 || self.uri.match(/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//)) { return self.emit('error', new Error('options.uri must be a path when using options.baseUrl')) } diff --git a/tests/test-baseUrl.js b/tests/test-baseUrl.js index a9a5e1378..24ba3f7f3 100644 --- a/tests/test-baseUrl.js +++ b/tests/test-baseUrl.js @@ -131,3 +131,12 @@ tape('error on baseUrl and uri with scheme-relative url', function (t) { t.end() }) }) + +tape('no error when scheme occurs later in path', function (t) { + request('/login?next=http://yourhome.com', { + baseUrl: s.url + '/path/' + }, function (err, resp, body) { + t.equal(err, null) + t.end() + }) +})