Skip to content

Commit eb33090

Browse files
author
Maxim Shirshin
authored
Chore: Fix logical operator priority (regression) to disallow GET/HEAD with non-empty body (#1369)
1 parent 7ba5bc9 commit eb33090

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/request.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export default class Request extends Body {
5959
method = method.toUpperCase();
6060

6161
// eslint-disable-next-line no-eq-null, eqeqeq
62-
if (((init.body != null || isRequest(input)) && input.body !== null) &&
62+
if ((init.body != null || (isRequest(input) && input.body !== null)) &&
6363
(method === 'GET' || method === 'HEAD')) {
6464
throw new TypeError('Request with GET/HEAD method cannot have body');
6565
}

test/request.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ describe('Request', () => {
123123
.to.throw(TypeError);
124124
expect(() => new Request(base, {body: 'a', method: 'head'}))
125125
.to.throw(TypeError);
126+
expect(() => new Request(new Request(base), {body: 'a'}))
127+
.to.throw(TypeError);
126128
});
127129

128130
it('should throw error when including credentials', () => {

0 commit comments

Comments
 (0)