-
Notifications
You must be signed in to change notification settings - Fork 600
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(fetch): Explicitly check for FormData type #1451
Conversation
Is it spec-compliant to do an |
It still does the |
What if we did something like |
Not needed, the current |
So there can't be a case where a
That's precisely why defining it as a static property would override its potentially mangled name. |
I don't think this makes things worse. Might be room for further improvement as per @NMinhNguyen's comments. |
On one hand, the current implementation of the core
isFormDataLike
helper is:undici/lib/core/util.js
Line 328 in 2ea8f03
On the other hand, the Fetch code has an actual
FormData
implementation.The latter's
constructor.name
is'FormData'
, so the combination of the two does work. So far, so good.Now, I'm using esbuild to bundle undici into my app. Because of some naming conflict, it renames the class to
FormData3
. And then, all hell breaks loose.To avoid that issue, this PR makes the Fetch part explicitly check the type of the given object.
It'd probably be better to update the core helper instead. I'd originally started to do that. Unfortunately, it introduced a circular dependency. It seemed solvable, but I didn't want to start moving things around just yet.