FIX: search params in returned links break iteration #405
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #404
buildURL
expects a pathname (or originAndPathname) to be passed, which does not contain any search parameters.If it does, however, the result will contain a broken url.
This happened in the example of the
getRefunds
helper, which used the returned URL which included ?testmode and appended limit params. The resulting URL looked like this:https://api.mollie.com/v2/payments/tr_paymentID/refunds?testmode=true?limit=128
The solution was to parse the URL into its pathname and query components, before passing it into
.iterate
.This issue concerned all helpers, which returned iterators.
Helpers, which only used
.get
did (accidentally) work and could have remained untouched, but I still updated them for consistency.My initial impulse was to also update
buildUrl
, which caused the concatenation issue.There are two options: allow existing SearchParams in the pathname and merge them or throw if there are params in the pathname.
I was leaning towards the latter, as the whole client consistently handles pathnames and query params separately.
Ultimately I decided to leave it as is, since any change (merge or throw) could lead to unexpected behaviour for users, if any networkClient call using it got overlooked.
That would make it a breaking change.
We might want to keep this in mind for the next major, though.