-
Notifications
You must be signed in to change notification settings - Fork 4
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
fix: Allow prefixUrl to work #370
Conversation
@@ -175,7 +180,7 @@ describe('fetch request', () => { | |||
|
|||
}); | |||
|
|||
it.only("sends own content-type header", async () => { | |||
it("sends own content-type header", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the only
meant none of the other tests in this file ran
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦♂️ thanks for fixing this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thanks for the contribution!
I'm going to have a think about disabling the test that verifies merging query parameters because I think that functionality is really important to keep.
@@ -175,7 +180,7 @@ describe('fetch request', () => { | |||
|
|||
}); | |||
|
|||
it.only("sends own content-type header", async () => { | |||
it("sends own content-type header", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦♂️ thanks for fixing this
src/test/fetch.request.test.ts
Outdated
it('merges query string parameters', async () => { | ||
expect.assertions(1); | ||
interceptor.intercept('/', 'get').query({ foo: '123', bar: '456' }).reply(200); | ||
|
||
const fetch = createFetch(got.extend({ searchParams: { bar: '456' } })); | ||
await assert200(fetch(url('/', { foo: '123' }))); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think disabling this might be problematic because I'd expect people to use it to add access tokens/API keys as a base on their clients 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about doing the URL parsing like below and restoring the code that sends searchParams
as a separate entity, restoring the deleted test and adding an extra test for prefixUrl
+ search params merging:
it("merges query string parameters with a prefix URL", async () => {
expect.assertions(1);
interceptor
.intercept("/", "get")
.query({ foo: "123", bar: "456" })
.reply(200);
const fetch = createFetch(
got.extend({
prefixUrl: ORIGIN,
searchParams: { bar: "456" },
})
);
await assert200(fetch("/?foo=123"));
});
Co-authored-by: Alex Gherghisan <alexghr@users.noreply.github.com>
@alexghr Just wanted to check in on this |
@alexghr checking in again, would love to get this merged |
## [4.0.5](v4.0.4...v4.0.5) (2024-07-19) ### Bug Fixes * Allow prefixUrl to work ([#370](#370)) ([c27a53a](c27a53a))
🎉 This PR is included in version 4.0.5 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This is most certainly a hack, but I was trying to maintain the current behaviour.
#369
I can also port this to main