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

Pass normalized options to the handler #532

Merged
merged 4 commits into from
Jul 25, 2018

Conversation

szmarczak
Copy link
Collaborator

That's just an improvement.

@szmarczak szmarczak mentioned this pull request Jul 19, 2018
7 tasks
if (!is.string(url) && !is.object(url)) {
if (options.baseUrl && (is.string(url) || is(url) === 'URL')) {
url = urlToOptions(new URLGlobal(url, options.baseUrl));
} else if (!is.string(url) && !is.object(url)) {
throw new TypeError(`Parameter \`url\` must be a string or object, not ${is(url)}`);
Copy link
Owner

Choose a reason for hiding this comment

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

I think this should be moved out of the if/else into a standalone if above:

if (!is.string(url) && !is.object(url)) {
	throw new TypeError(`Parameter \`url\` must be a string or object, not ${is(url)}`);
}

if (options.baseUrl && (is.string(url) || is(url) === 'URL')) {
...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep. Doing right now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done. Also I've moved baseUrl handling into if (is.string(url)) { ... } to avoid checking is.string(url) two times.

@sindresorhus
Copy link
Owner

Other than the #532 (comment) nitpick, this looks good to me :)

@sindresorhus sindresorhus merged commit 2649270 into sindresorhus:master Jul 25, 2018
@szmarczak szmarczak deleted the better-handler 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