Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set href as request.js uses it #1820

Merged
merged 2 commits into from Oct 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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