Skip to content

Commit 8cba743

Browse files
authored
avoid duplicate header, check the ancestor origin (#800)
the condition wasn't good due to the iframe, so now im checking the ancestor origin instead of .origin
1 parent 0f154c1 commit 8cba743

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/space-header/src/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ import { inject } from "./inject";
99
async function main(initialSpace: string | Space, options?: Options) {
1010
if (window === undefined) return console.error("Please run this script in a browser environment");
1111
// Don't run on huggingface.co to avoid duplicate headers
12-
if (window.location?.origin === "https://huggingface.co") return;
12+
const has_huggingface_ancestor = Object.values(
13+
window.location?.ancestorOrigins ?? {
14+
0: window.document.referrer,
15+
}
16+
).some((origin) => new URL(origin)?.origin === "https://huggingface.co");
17+
if (has_huggingface_ancestor) return;
1318

1419
inject_fonts();
1520

0 commit comments

Comments
 (0)