@pantoken/vite-workspace-orchestrator 0.1.1 → 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.
Files changed (2) hide show
  1. package/dist/index.mjs +8 -2
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { readFileSync, watch } from "node:fs";
2
- import { matchesGlob, resolve } from "node:path";
2
+ import { isAbsolute, matchesGlob, relative, resolve } from "node:path";
3
3
  import { spawn } from "node:child_process";
4
4
  //#region src/file-server.ts
5
5
  /**
@@ -22,7 +22,13 @@ function mountFileServers(fileServers, middlewares) {
22
22
  return;
23
23
  }
24
24
  const resolved = entry.pathTransform ? entry.pathTransform(filePath) : filePath;
25
- const fullPath = resolve(entry.serveDir, resolved.slice(1));
25
+ const serveRoot = resolve(entry.serveDir);
26
+ const fullPath = resolve(serveRoot, resolved.slice(1));
27
+ const rel = relative(serveRoot, fullPath);
28
+ if (rel.startsWith("..") || isAbsolute(rel)) {
29
+ next();
30
+ return;
31
+ }
26
32
  try {
27
33
  const content = readFileSync(fullPath, "utf8");
28
34
  res.setHeader("Content-Type", entry.contentType);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pantoken/vite-workspace-orchestrator",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Vite dev-server plugin that watches upstream workspace packages and rebuilds them (and their dependents) when source changes.",
5
5
  "homepage": "https://pantoken.iywahl.com",
6
6
  "bugs": "https://github.com/thedannywahl/pantoken/issues",