From d7a66baac7bb3c0915b921997e401adf4718baaf Mon Sep 17 00:00:00 2001 From: Vsevolod Strukchinsky Date: Thu, 25 Jun 2015 21:28:00 +0300 Subject: [PATCH] Try pathname, if no path is specified Closes #72 --- index.js | 4 ++++ test/test-arguments.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 134cb88..b096476 100644 --- a/index.js +++ b/index.js @@ -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); diff --git a/test/test-arguments.js b/test/test-arguments.js index 36b4b09..cff95af 100644 --- a/test/test-arguments.js +++ b/test/test-arguments.js @@ -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(); }); });