Chore: Fix logical operator priority (regression) to disallow GET/HEAD with non-empty body (#1369)
This commit is contained in:
parent
7ba5bc9e0a
commit
eb33090b81
|
@ -59,7 +59,7 @@ export default class Request extends Body {
|
||||||
method = method.toUpperCase();
|
method = method.toUpperCase();
|
||||||
|
|
||||||
// eslint-disable-next-line no-eq-null, eqeqeq
|
// eslint-disable-next-line no-eq-null, eqeqeq
|
||||||
if (((init.body != null || isRequest(input)) && input.body !== null) &&
|
if ((init.body != null || (isRequest(input) && input.body !== null)) &&
|
||||||
(method === 'GET' || method === 'HEAD')) {
|
(method === 'GET' || method === 'HEAD')) {
|
||||||
throw new TypeError('Request with GET/HEAD method cannot have body');
|
throw new TypeError('Request with GET/HEAD method cannot have body');
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,6 +123,8 @@ describe('Request', () => {
|
||||||
.to.throw(TypeError);
|
.to.throw(TypeError);
|
||||||
expect(() => new Request(base, {body: 'a', method: 'head'}))
|
expect(() => new Request(base, {body: 'a', method: 'head'}))
|
||||||
.to.throw(TypeError);
|
.to.throw(TypeError);
|
||||||
|
expect(() => new Request(new Request(base), {body: 'a'}))
|
||||||
|
.to.throw(TypeError);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw error when including credentials', () => {
|
it('should throw error when including credentials', () => {
|
||||||
|
|
Loading…
Reference in New Issue