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() + }) +})