cert-coach-web 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.
@@ -383,8 +383,13 @@ export function createStudyServer({ root, loop, token = "", chat = null, runtime
383
383
  if (method === "GET" && url.pathname === "/preview.js") {
384
384
  return sendFile(res, path.join(PUBLIC, "preview.js"), "text/javascript; charset=utf-8");
385
385
  }
386
- if (method === "GET" && url.pathname === "/app.js") {
387
- return sendFile(res, path.join(PUBLIC, "app.js"), "text/javascript; charset=utf-8");
386
+ // Serve any top-level module in web/public: /app.js, /spa-logic.js,
387
+ // /spa-render.js, /spa-store.js, ... The pattern forbids slashes and dots
388
+ // except the trailing .js, so it cannot escape PUBLIC.
389
+ if (method === "GET" && /^\/[a-z0-9-]+\.js$/.test(url.pathname)) {
390
+ const name = url.pathname.slice(1);
391
+ const file = path.join(PUBLIC, name);
392
+ if (fs.existsSync(file)) return sendFile(res, file, "text/javascript; charset=utf-8");
388
393
  }
389
394
  if (method === "GET" && url.pathname === "/styles.css") {
390
395
  return sendFile(res, path.join(PUBLIC, "styles.css"), "text/css; charset=utf-8");