-
-
Notifications
You must be signed in to change notification settings - Fork 362
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 TypeError on Edge 18 #264
Conversation
@sindresorhus if this fix looks right to you, do you think it can be released in a short time... Just to know, otherwise I'll use a fork meanwhile. Thanks for your work. |
For info I also had publish an hotfix in this package: https://www.npmjs.com/package/belgattitude-ky.
Webpack/Nextjs users can alias it to ky.
Just a rush solution... |
The constructor is not the only place that we use It's for precisely these kinds of reasons that we cannot accept this without a test. I disagree that it's hard to test. You should be able to make a test that monkey patches the Something along the lines of... const OriginalHeaders = Headers;
global.Headers = class Headers {
constructor(init) {
// Do what the offending browsers do here...
// e.g. if (init === undefined) { throw new Error() }
}
}
// ... test Ky ...
global.Headers = OriginalHeaders; |
Agree haven't thought about extend... and was not sure about how throwing an error would be received in relation to possible BC. I'll update tonight. Thanks @sholladay |
@sholladay The approach taken by @JosNun #261 is equivalent, but tackles the issue in the Both valid, what's your feeling about the road to take. Either way I'm fine |
I prefer the approach in #261 because it should handle |
@sholladay @JosNun It's actually a better idea to do it like #261 ... I'm about to close this one if you agree |
Fine with me |
Fixes TypeError with edge 18 and probably a bunch of older browsers. I took a different approach from #261, while we are tackling the same problem.
IMO the fix should not be made in
mergeHeaders
, but in the Ky constructor. Thethis._input
isstring|Url|Request
, headers won't be present if a string is passed (url)... Modern browsers won't care so much and merge with 'undefined', but the error seems legit to me.Regarding testing, it's almost impossible to test this. At least I've tested on browserstack with success (edge 18 on Window 10).
Will close
Notes:
As reported on sentry