Skip to content

Commit cc400bf

Browse files
committed
[chrome] fix inject url resolution
1 parent 96587c4 commit cc400bf

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/chrome/src/IsolatedFrame.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ function getRootDomain(url: URL): string {
132132
return tldts.getDomain(url.href) || url.hostname;
133133
}
134134

135+
const virtualInjectUrl = "/inject.js";
136+
135137
function makeController(url: URL): Controller {
136138
let originurl = new URL(ISOLATION_ORIGIN);
137139
let baseurl = new URL(
@@ -175,7 +177,11 @@ function makeController(url: URL): Controller {
175177
const head = findhead(handler.root as Node as Element)!;
176178

177179
// inject after the scramjet scripts and before the rest of the page
178-
head.children.splice(3, 0, new Element("script", { src: injectScript }));
180+
head.children.splice(
181+
3,
182+
0,
183+
new Element("script", { src: virtualInjectUrl })
184+
);
179185
});
180186

181187
const controller = {
@@ -240,7 +246,7 @@ const methods = {
240246
return [await makeWasmResponse(), undefined];
241247
} else if (data.rawUrl.pathname === cfg.files.all) {
242248
return [await makeAllResponse(), undefined];
243-
} else if (data.rawUrl.pathname === "/inject.js") {
249+
} else if (data.rawUrl.pathname === virtualInjectUrl) {
244250
return [
245251
await fetch(injectScript).then(async (x) => {
246252
const text = await x.text();

0 commit comments

Comments
 (0)