Skip to content

Commit

Permalink
Merge 2eb6831 into 253c5e5
Browse files Browse the repository at this point in the history
  • Loading branch information
zaverden committed Oct 28, 2017
2 parents 253c5e5 + 2eb6831 commit b643655
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion request.js
Expand Up @@ -197,7 +197,7 @@ Request.prototype.init = function (options) {

// If there's a baseUrl, then use it as the base URL (i.e. uri must be
// specified as a relative path and is appended to baseUrl).
if (self.baseUrl) {
if (self.baseUrl && (self.uri || self.uri === '')) {
if (typeof self.baseUrl !== 'string') {
return self.emit('error', new Error('options.baseUrl must be a string'))
}
Expand Down
7 changes: 7 additions & 0 deletions tests/test-errors.js
Expand Up @@ -12,6 +12,13 @@ tape('without uri', function (t) {
t.end()
})

tape('without uri but with baseUrl', function (t) {
t.throws(function () {
request({ baseUrl: 'https://github.com' })
}, /^Error: options\.uri is a required argument$/)
t.end()
})

tape('invalid uri 1', function (t) {
t.throws(function () {
request({
Expand Down

0 comments on commit b643655

Please sign in to comment.