Skip to content

Commit

Permalink
Merge pull request #1820 from mgenereu/patch-2
Browse files Browse the repository at this point in the history
Set href as request.js uses it
  • Loading branch information
simov committed Oct 17, 2015
2 parents 1ff166b + 2c1296d commit 4355b31
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions request.js
Expand Up @@ -249,6 +249,11 @@ Request.prototype.init = function (options) {
self.uri = url.parse(self.uri)
}

// Some URL objects are not from a URL parsed string and need href added
if (!self.uri.href) {
self.uri.href = url.format(self.uri)
}

// DEPRECATED: Warning for users of the old Unix Sockets URL Scheme
if (self.uri.protocol === 'unix:') {
return self.emit('error', new Error('`unix://` URL scheme is no longer supported. Please use the format `http://unix:SOCKET:PATH`'))
Expand Down
17 changes: 17 additions & 0 deletions tests/test-isUrl.js
Expand Up @@ -94,6 +94,23 @@ tape('hostname and port 3', function(t) {
})
})

tape('hostname and query string', function(t) {
request({
uri: {
protocol: 'http:',
hostname: 'localhost',
port: 6767
},
qs: {
test: 'test'
}
}, function(err, res, body) {
t.equal(err, null)
t.equal(body, 'ok')
t.end()
})
})

tape('cleanup', function(t) {
s.close(function() {
t.end()
Expand Down

0 comments on commit 4355b31

Please sign in to comment.