@cydm/magic-shell-agent-node 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,6 +24,7 @@ function guessContentType(filePath) {
24
24
  function findWorkbenchRoot() {
25
25
  const currentDir = path.dirname(fileURLToPath(import.meta.url));
26
26
  const candidates = [
27
+ path.resolve(currentDir, "./workbench"),
27
28
  path.resolve(currentDir, "../../../apps/web/src"),
28
29
  path.resolve(currentDir, "../../../../apps/web/src"),
29
30
  path.resolve(process.cwd(), "apps/web/src"),
@@ -130,8 +131,8 @@ export class LocalDirectServer {
130
131
  res.end("Workbench files not found");
131
132
  return;
132
133
  }
133
- const relativePath = url.pathname === "/" ? "/index.html" : url.pathname;
134
- const normalizedPath = path.normalize(relativePath).replace(/^(\.\.[/\\])+/, "");
134
+ const relativePath = url.pathname === "/" ? "index.html" : url.pathname.replace(/^\/+/, "");
135
+ const normalizedPath = path.normalize(relativePath).replace(/^(\.\.[/\\])+/, "").replace(/^[/\\]+/, "");
135
136
  const targetPath = path.join(this.workbenchRoot, normalizedPath);
136
137
  const safeRoot = path.resolve(this.workbenchRoot);
137
138
  const safeTarget = path.resolve(targetPath);