forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocation.ts
More file actions
30 lines (28 loc) · 767 Bytes
/
Copy pathlocation.ts
File metadata and controls
30 lines (28 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
* Polyfill: window.location
*
* Required by shouldShowDevConsole (hostname check) and agent runtime
* URL resolution (window.location.origin). Uses an obviously invalid
* hostname to avoid tricking localhost-detection code.
*
* Skipped if window.location is already defined.
*
* Usage:
* import "@copilotkit/react-native/polyfills/location";
*/
export {};
if (typeof window !== "undefined") {
const w = window as unknown as Record<string, unknown>;
if (!w.location) {
w.location = {
hostname: "react-native.invalid",
href: "http://react-native.invalid",
origin: "http://react-native.invalid",
protocol: "http:",
host: "react-native.invalid",
pathname: "/",
search: "",
hash: "",
};
}
}