Skip to content

Commit

Permalink
Merge 41e1e65 into a287f8e
Browse files Browse the repository at this point in the history
  • Loading branch information
alextes committed Mar 26, 2017
2 parents a287f8e + 41e1e65 commit 44c08e9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const unzipResponse = require('unzip-response');
const createErrorClass = require('create-error-class');
const isRetryAllowed = require('is-retry-allowed');
const Buffer = require('safe-buffer').Buffer;
const isURL = require('isurl');
const pkg = require('./package');

function requestAsEventEmitter(opts) {
Expand Down Expand Up @@ -206,6 +207,10 @@ function normalizeArguments(url, opts) {
}
}

if (isURL(url)) {
url = urlParseLax(url.href);
}

opts = Object.assign(
{
protocol: 'http:',
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"is-redirect": "^1.0.0",
"is-retry-allowed": "^1.0.0",
"is-stream": "^1.0.0",
"isurl": "^1.0.0-alpha3",
"lowercase-keys": "^1.0.0",
"safe-buffer": "^5.0.1",
"timed-out": "^4.0.0",
Expand All @@ -64,6 +65,7 @@
"pem": "^1.4.4",
"pify": "^2.3.0",
"tempfile": "^1.1.1",
"whatwg-url": "^4.6.0",
"xo": "^0.18.0"
},
"ava": {
Expand Down
7 changes: 7 additions & 0 deletions test/arguments.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import whatwgURL from 'whatwg-url';
import test from 'ava';
import got from '../';
import {createServer} from './helpers/server';

const URL = whatwgURL.URL;
let s;

test.before('setup', async () => {
Expand Down Expand Up @@ -65,6 +67,11 @@ test('should throw with auth in url', async t => {
}
});

test('whatwg-url support', async () => {
const wURL = new URL(`${s.url}/test`);
await got(wURL);
});

test.after('cleanup', async () => {
await s.close();
});

0 comments on commit 44c08e9

Please sign in to comment.