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

Loosen unnecessary restrictions on the body option #521

Merged
merged 2 commits into from
Jul 14, 2018

Conversation

szmarczak
Copy link
Collaborator

@szmarczak szmarczak commented Jul 14, 2018

Fixes #381

test/error.js Outdated
body.push(chunk);
}).on('end', () => {
res.end(Buffer.concat(body).toString());
});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use get-stream here for simplicity

test/error.js Outdated
@@ -54,17 +63,27 @@ test('dns message', async t => {

test('options.body error message', async t => {
const err = await t.throws(got(s.url, {body: {}}));
t.regex(err.message, /The `body` option must be a stream\.Readable, string or Buffer/);
t.is(err.message, 'The `body` option must be a stream.Readable, string or Buffer');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should change all of the t.throws assertions to the new format. Should not be done in this PR though. Just a note to myself.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so after this gets merged I'll do another PR for that.

test/error.js Outdated
this.a = 123;
}

const {body} = (await got(`${s.url}/body`, {body: new CustomObject(), json: true}));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need parens around await

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. Forgot because before I did const body = (...).body then I used const { body } = ... :)

@sindresorhus sindresorhus merged commit 7a49ce7 into sindresorhus:master Jul 14, 2018
@szmarczak szmarczak deleted the loosen-restriction branch January 17, 2019 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants