From 69b8877956f9c061ed01d127bf34f0b7d51f9085 Mon Sep 17 00:00:00 2001 From: Simon Graband Date: Wed, 3 Jul 2024 17:20:14 +0200 Subject: [PATCH] Use relative paths for ctx.importScripts() (#13854) Before we tried to load absolute paths e.g. `/context/`. This is a problem, when working in deployed use cases, where Theia might be hosted under a path (e.g. try.theia-cloud.io). Because then the loaded path will be from the root of the page and not, like wanted, from the current path. Simply changing it to relative paths (e.g. `./context/`) solves this issue. Fixes #13813 --- packages/plugin-ext/src/hosted/browser/worker/worker-main.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/plugin-ext/src/hosted/browser/worker/worker-main.ts b/packages/plugin-ext/src/hosted/browser/worker/worker-main.ts index 56045b5f839fe..3739987040f1a 100644 --- a/packages/plugin-ext/src/hosted/browser/worker/worker-main.ts +++ b/packages/plugin-ext/src/hosted/browser/worker/worker-main.ts @@ -45,7 +45,7 @@ const pluginsModulesNames = new Map(); const scripts = new Set(); function initialize(contextPath: string, pluginMetadata: PluginMetadata): void { - const path = '/context/' + contextPath; + const path = './context/' + contextPath; if (!scripts.has(path)) { ctx.importScripts(path); @@ -70,7 +70,7 @@ pluginManager.setPluginHost({ ctx.frontendModuleName = plugin.lifecycle.frontendModuleName; } - ctx.importScripts('/hostedPlugin/' + getPluginId(plugin.model) + '/' + plugin.pluginPath); + ctx.importScripts('./hostedPlugin/' + getPluginId(plugin.model) + '/' + plugin.pluginPath); } }