Skip to content

Commit

Permalink
Try pathname, if no path is specified
Browse files Browse the repository at this point in the history
Closes #72
  • Loading branch information
floatdrop committed Jun 25, 2015
1 parent b7d4f8c commit d7a66ba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ function got(url, opts, cb) {
'accept-encoding': 'gzip,deflate'
}, lowercaseKeys(opts.headers));

if (opts.pathname) {
opts.path = opts.pathname;
}

if (opts.query) {
if (typeof opts.query !== 'string') {
opts.query = querystring.stringify(opts.query);
Expand Down
2 changes: 1 addition & 1 deletion test/test-arguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ test('overrides querystring from opts', function (t) {

test('pathname confusion', function (t) {
got({protocol: 'http:', hostname: s.host, port: s.port, pathname: '/test'}, function (err) {
t.ok(/http:\/\/localhost:6767\/test response code/.test(err));
t.error(err);
t.end();
});
});
Expand Down

0 comments on commit d7a66ba

Please sign in to comment.