Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
@@ -8,6 +8,59 @@ process.env.CRYPTO_SECRET ??= "test-crypto-secret";
|
||||
import i18next from "i18next";
|
||||
import enTranslations from "./apps/web/public/locales/en/translations.json";
|
||||
|
||||
// Node keeps its native undici Request in the jsdom environment while jsdom
|
||||
// installs a realm-local URLSearchParams constructor. Undici performs a strict
|
||||
// WebIDL brand check that differs between Node releases. Serialize form bodies
|
||||
// at the Request boundary instead of replacing the global constructor so both
|
||||
// browser-facing URLSearchParams behavior and native Request parsing stay stable.
|
||||
const NativeRequest = globalThis.Request;
|
||||
|
||||
function isUrlSearchParamsBody(body: BodyInit | null | undefined): body is URLSearchParams {
|
||||
return body !== null && typeof body === "object" && Object.prototype.toString.call(body) === "[object URLSearchParams]";
|
||||
}
|
||||
|
||||
function acceptsNativeRequestSignal(signal: AbortSignal | null | undefined): boolean {
|
||||
if (!signal) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
new NativeRequest("https://app.example.test/__signal_compatibility__", { signal });
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class RealmSafeRequest extends NativeRequest {
|
||||
constructor(input: RequestInfo | URL, init?: RequestInit) {
|
||||
if (!init) {
|
||||
super(input);
|
||||
return;
|
||||
}
|
||||
|
||||
const safeInit = acceptsNativeRequestSignal(init.signal) ? init : { ...init, signal: undefined };
|
||||
|
||||
if (!isUrlSearchParamsBody(safeInit.body)) {
|
||||
super(input, safeInit);
|
||||
return;
|
||||
}
|
||||
|
||||
const headers = new Headers(safeInit.headers);
|
||||
if (!headers.has("content-type")) {
|
||||
headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8");
|
||||
}
|
||||
|
||||
super(input, { ...safeInit, body: safeInit.body.toString(), headers });
|
||||
}
|
||||
}
|
||||
|
||||
Object.defineProperty(globalThis, "Request", {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: RealmSafeRequest,
|
||||
});
|
||||
|
||||
if (!i18next.isInitialized) {
|
||||
await i18next.init({
|
||||
lng: "en",
|
||||
|
||||
Reference in new issue
Block a user