fix: preserve plugin manifest compatibility

This commit is contained in:
Federico Jaramillo Martinez
2026-07-13 12:29:21 +02:00
parent 0d3096973e
commit a9bcfe25ff
7 changed files with 36 additions and 22 deletions
@@ -95,10 +95,13 @@ function rewriteRemotePluginManifest(machineId: string, manifest: RemotePluginMa
function remotePluginModulePath(pluginId: string, module: string): { path: string; query: string } | undefined {
if (!isPiWebPluginId(pluginId)) return undefined;
const prefix = `/pi-web-plugins/${encodeURIComponent(pluginId)}/`;
const manifestUrl = new URL("/pi-web-plugins/manifest.json", "http://pi-web.local");
const pluginRootUrl = new URL(prefix, "http://pi-web.local");
const manifestUrl = new URL("/pi-web-plugins/manifest.json", pluginRootUrl);
try {
const url = new URL(module, manifestUrl);
if (url.origin !== manifestUrl.origin || !url.pathname.startsWith(prefix)) return undefined;
// An explicit ./<plugin-id>/ prefix is manifest-relative; bare paths retain the legacy plugin-root-relative contract.
const baseUrl = module.startsWith("./") ? manifestUrl : pluginRootUrl;
const url = new URL(module, baseUrl);
if (url.origin !== pluginRootUrl.origin || !url.pathname.startsWith(prefix)) return undefined;
const path = safeRemotePluginAssetPath(url.pathname.slice(prefix.length));
return path === undefined ? undefined : { path, query: url.search };
} catch {