Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Request): Fix logical operator priority to disallow GET/HEAD with non-empty body #1369

Merged
merged 1 commit into from Dec 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/request.js
Expand Up @@ -60,7 +60,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