Skip to content

Commit

Permalink
Chore: Fix logical operator priority (regression) to disallow GET/HEA…
Browse files Browse the repository at this point in the history
…D with non-empty body (#1369)
  • Loading branch information
Maxim Shirshin committed Dec 6, 2021
1 parent 7ba5bc9 commit eb33090
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/request.js
Expand Up @@ -59,7 +59,7 @@ export default class Request extends Body {
method = method.toUpperCase();

// 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')) {
throw new TypeError('Request with GET/HEAD method cannot have body');
}
Expand Down
2 changes: 2 additions & 0 deletions test/request.js
Expand Up @@ -123,6 +123,8 @@ describe('Request', () => {
.to.throw(TypeError);
expect(() => new Request(base, {body: 'a', method: 'head'}))
.to.throw(TypeError);
expect(() => new Request(new Request(base), {body: 'a'}))
.to.throw(TypeError);
});

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

0 comments on commit eb33090

Please sign in to comment.