Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

feat(buildFetchUrl): enable optional ids via question mark #13

Merged
merged 1 commit into from
Apr 28, 2020

Conversation

PatNeedham
Copy link
Contributor

No description provided.

@PatNeedham PatNeedham requested a review from a team as a code owner March 30, 2020 12:50
@JAdshead
Copy link
Contributor

JAdshead commented Apr 2, 2020

Hi @PatNeedham can you also include an update the readme ?

__tests__/helpers/url.spec.js Show resolved Hide resolved
__tests__/helpers/url.spec.js Show resolved Hide resolved
README.md Show resolved Hide resolved
Copy link
Contributor

@mtomcal mtomcal left a comment

Choose a reason for hiding this comment

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

Some questions about trailing ? and a stylistic change. We really appreciate your contribution.

src/helpers/url.js Outdated Show resolved Hide resolved
query: { userId: 'questionable?' },
},
});
expect(url).toBe('http://api.domain.com/users?userId=questionable?');
Copy link
Contributor

Choose a reason for hiding this comment

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

What use case would require a trailing ??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Honestly not sure, I was mainly trying to think of all the possible cases that could cause it to fail, regardless of how realistic they are.

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha. Okay, Im thinking one more unit test for this case would be good: http://api.domain.com/users/:user?/comments and pass:

opts: {
  query: { someModifier: 'questionable?' },
},

without a :user defined and see if:
expect(url).toBe('http://api.domain.com/users/comments?someModifier=questionable?')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Test fails!
image
Ampersand is being included instead of the question mark. Well at least initially that was the case. But moving the .replace(/\?\//g, '/'); to the end of the initial builtUrl value (before the addQueryParams call) got it to pass, and all remaining tests pass as well.

@JAdshead
Copy link
Contributor

@PatNeedham you will need to amend your last commit as its causing the build to fail.

JAdshead
JAdshead previously approved these changes Apr 23, 2020
Copy link
Contributor

@mtomcal mtomcal left a comment

Choose a reason for hiding this comment

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

Add one more test case and rebase and reword commits that dont follow Conventional Commits https://www.conventionalcommits.org/en/v1.0.0/#summary Thanks again!

@PatNeedham
Copy link
Contributor Author

Add one more test case and rebase and reword commits that dont follow Conventional Commits https://www.conventionalcommits.org/en/v1.0.0/#summary Thanks again!

Since this change from the first commit is no longer taking place (as the replace is now being called on the replaceUrlParams return value), would it be better to squash the two commits into the original instead of rewording the second one?
image

This one becomes no longer necessary.

@mtomcal
Copy link
Contributor

mtomcal commented Apr 24, 2020

@PatNeedham Yeah definitely go ahead and squash commits in this PR and reword the commit to follow convention. That will fix things. Thanks!

@mtomcal mtomcal merged commit 82e1f54 into americanexpress:master Apr 28, 2020
@oneamexbot
Copy link
Contributor

🎉 This PR is included in version 1.9.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants