Skip to content

Commit

Permalink
Remove error thrown for URLs with auth component (#676)
Browse files Browse the repository at this point in the history
  • Loading branch information
alextes authored and sindresorhus committed Dec 18, 2018
1 parent 3e0edd8 commit 5d20a43
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 25 deletions.
4 changes: 0 additions & 4 deletions source/normalize-arguments.js
Expand Up @@ -116,11 +116,7 @@ const normalize = (url, options, defaults) => {
url = urlToOptions(new URL(url, options.baseUrl));
} else {
url = url.replace(/^unix:/, 'http://$&');

url = urlParseLax(url);
if (url.auth) {
throw new Error('Basic authentication must be done with the `auth` option');
}
}
} else if (is(url) === 'URL') {
url = urlToOptions(url);
Expand Down
21 changes: 0 additions & 21 deletions test/arguments.js
Expand Up @@ -130,27 +130,6 @@ test('should ignore empty query object', async t => {
t.is((await got(`${s.url}/test`, {query: {}})).requestUrl, `${s.url}/test`);
});

test('should throw with auth in url string', async t => {
await t.throwsAsync(
got('https://test:45d3ps453@account.myservice.com/api/token'),
{
message: 'Basic authentication must be done with the `auth` option'
}
);
});

test('does not throw with auth in url object', async t => {
await t.notThrowsAsync(
got({
auth: 'foo:bar',
hostname: s.host,
port: s.port,
protocol: 'http:',
path: '/test'
})
);
});

test('should throw when body is set to object', async t => {
await t.throwsAsync(got(`${s.url}/`, {body: {}}), TypeError);
});
Expand Down

0 comments on commit 5d20a43

Please sign in to comment.