diff --git a/hemx-js/runtime/hemx.js b/hemx-js/runtime/hemx.js index 97cdaec..7c31dbd 100644 --- a/hemx-js/runtime/hemx.js +++ b/hemx-js/runtime/hemx.js @@ -153,7 +153,7 @@ function urlEncoded(data) { const encoded = new URLSearchParams(); for (const [name, value] of data.entries()) { - if (value instanceof File) continue; + if (typeof File !== "undefined" && value instanceof File) continue; encoded.append(name, value); } return encoded; diff --git a/hemx-js/tests/runtime.rs b/hemx-js/tests/runtime.rs index df2ee45..47dee5c 100644 --- a/hemx-js/tests/runtime.rs +++ b/hemx-js/tests/runtime.rs @@ -17,7 +17,7 @@ fn runtime_preserves_multipart_file_upload_fallback_shape() { assert!(source.contains( "multipart: form && String(form.enctype).toLowerCase() === \"multipart/form-data\"" )); - assert!(source.contains("if (value instanceof File) continue")); + assert!(source.contains("if (typeof File !== \"undefined\" && value instanceof File) continue")); assert!(source.contains("return multipart ? data : urlEncoded(data)")); assert!(source.contains("if (body instanceof URLSearchParams) headers[\"Content-Type\"] = \"application/x-www-form-urlencoded;charset=UTF-8\"")); }