Improve coverage (#779)

This commit is contained in:
Antoni Kepinski 2020-05-17 15:28:26 +02:00 committed by GitHub
parent 0936a9af0a
commit 7d36f3b247
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 11 deletions

View File

@ -203,11 +203,6 @@ export function getNodeRequestOptions(request) {
headers.set('Accept', '*/*');
}
// Basic fetch
if (!parsedURL.protocol || !parsedURL.hostname) {
throw new TypeError('Only absolute URLs are supported');
}
if (!/^https?:$/.test(parsedURL.protocol)) {
throw new TypeError('Only HTTP(S) protocols are supported');
}

View File

@ -102,17 +102,17 @@ describe('Request', () => {
});
it('should throw error with GET/HEAD requests with body', () => {
expect(() => new Request('.', {body: ''}))
expect(() => new Request(base, {body: ''}))
.to.throw(TypeError);
expect(() => new Request('.', {body: 'a'}))
expect(() => new Request(base, {body: 'a'}))
.to.throw(TypeError);
expect(() => new Request('.', {body: '', method: 'HEAD'}))
expect(() => new Request(base, {body: '', method: 'HEAD'}))
.to.throw(TypeError);
expect(() => new Request('.', {body: 'a', method: 'HEAD'}))
expect(() => new Request(base, {body: 'a', method: 'HEAD'}))
.to.throw(TypeError);
expect(() => new Request('.', {body: 'a', method: 'get'}))
expect(() => new Request(base, {body: 'a', method: 'get'}))
.to.throw(TypeError);
expect(() => new Request('.', {body: 'a', method: 'head'}))
expect(() => new Request(base, {body: 'a', method: 'head'}))
.to.throw(TypeError);
});