Skip to content

Conversation

@szmarczak
Copy link
Collaborator

@szmarczak szmarczak commented Aug 23, 2018

Fixes #562

szmarczak and others added 2 commits August 23, 2018 12:14

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
const instanceA = got.extend({baseUrl: `${s.url}/test/`});
const {body} = await instanceA('/foobar');
t.is(body, `/test/foobar`);
});
Copy link
Owner

Choose a reason for hiding this comment

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

Can you also add a test with await instanceA('foobar');?

Copy link
Owner

Choose a reason for hiding this comment

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

And a couple of tests where the baseUrl is a WHATWG URL object.

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

return options;
};

module.exports.prenormalize = prenormalize;
Copy link
Owner

Choose a reason for hiding this comment

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

prenormalize is not a word, so should be preNormalize

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure

@sindresorhus
Copy link
Owner

The docs needs to be updated too.

@sindresorhus
Copy link
Owner

Rewrite the baseUrl option

Would be more descriptive to title the PR:

Normalize the URL in the baseUrl option

@sindresorhus
Copy link
Owner

Can you comment on why it was necessary to split it out into a preNormalize step?

@szmarczak
Copy link
Collaborator Author

Can you comment on why it was necessary to split it out into a preNormalize step?

Code comment or GitHub comment?

@sindresorhus
Copy link
Owner

Just a comment on this thread is fine.

szmarczak and others added 3 commits August 23, 2018 12:56

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

const retryAfterStatusCodes = new Set([413, 429, 503]);

const preNormalize = options => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've split normalize-argument.js into two parts:

  • preNormalize handles all the stuff which is related with static options like baseUrl, followRedirect, hooks etc.
    It is used in got.create() to normalize defaults.options.
  • normalize does preNormalize + handles all the stuff related with dynamic options like url, headers, body etc.

szmarczak and others added 3 commits August 23, 2018 13:24

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@sindresorhus sindresorhus changed the title Rewrite the baseUrl option Normalize the URL in the baseUrl option Aug 23, 2018
@sindresorhus sindresorhus merged commit c901c46 into sindresorhus:master Aug 23, 2018
@sindresorhus
Copy link
Owner

Looking great!

68747470733a2f2f6d656469612e67697068792e636f6d2f6d656469612f6c3045786b3845557a534c7372457245512f67697068792e676966

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