summaryrefslogtreecommitdiff
path: root/runtime/js/11_workers.js
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/js/11_workers.js')
-rw-r--r--runtime/js/11_workers.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/runtime/js/11_workers.js b/runtime/js/11_workers.js
index 4989cd4b5..57f420728 100644
--- a/runtime/js/11_workers.js
+++ b/runtime/js/11_workers.js
@@ -3,6 +3,7 @@
((window) => {
const core = window.Deno.core;
const { Window } = window.__bootstrap.globalInterfaces;
+ const { getLocationHref } = window.__bootstrap.location;
const { log, pathFromURL } = window.__bootstrap.util;
const { defineEventHandler } = window.__bootstrap.webUtil;
const build = window.__bootstrap.build.build;
@@ -127,6 +128,7 @@
constructor(specifier, options = {}) {
super();
+ specifier = String(specifier);
const {
deno = {},
name = "unknown",
@@ -177,6 +179,16 @@
const hasSourceCode = false;
const sourceCode = decoder.decode(new Uint8Array());
+ if (
+ specifier.startsWith("./") || specifier.startsWith("../") ||
+ specifier.startsWith("/") || type == "classic"
+ ) {
+ const baseUrl = getLocationHref();
+ if (baseUrl != null) {
+ specifier = new URL(specifier, baseUrl).href;
+ }
+ }
+
const { id } = createWorker(
specifier,
hasSourceCode,