summaryrefslogtreecommitdiff
path: root/skills/brainstorming/scripts
diff options
context:
space:
mode:
authorJesse Vincent <jesse@primeradiant.com>2026-06-09 14:53:48 -0700
committerDrew Ritter <drew@primeradiant.com>2026-06-16 10:09:45 -0700
commit2b108b7dc2896df01a58384a3ff46e71ba04e9e2 (patch)
tree36f7533a1f13ef3eb6952da0acec384da081be01 /skills/brainstorming/scripts
parent565845f251495cd041de2dedef37917bb5b6805b (diff)
fix(brainstorm-server): ignore macOS resource-fork dotfiles
On macOS (and ExFAT/SMB volumes) the OS writes ._<name>.html sidecar files holding binary resource-fork metadata. These end with .html, so they passed the content filter and could be picked as the newest screen — serving binary garbage to the browser instead of the mockup — or fetched via /files/. Skip dotfiles (leading '.') at all four sites that list or serve content: getNewestScreen, the /files/ endpoint, the known-files seed, and the fs.watch handler. Tests cover serving (/ and /files/) and the watch path (a ._ file must not trigger a reload). Refs #950
Diffstat (limited to 'skills/brainstorming/scripts')
-rw-r--r--skills/brainstorming/scripts/server.cjs12
1 files changed, 6 insertions, 6 deletions
diff --git a/skills/brainstorming/scripts/server.cjs b/skills/brainstorming/scripts/server.cjs
index 79661a9..78bf7c3 100644
--- a/skills/brainstorming/scripts/server.cjs
+++ b/skills/brainstorming/scripts/server.cjs
@@ -124,7 +124,7 @@ function wrapInFrame(content) {
function getNewestScreen() {
const files = fs.readdirSync(CONTENT_DIR)
- .filter(f => f.endsWith('.html'))
+ .filter(f => !f.startsWith('.') && f.endsWith('.html'))
.map(f => {
const fp = path.join(CONTENT_DIR, f);
return { path: fp, mtime: fs.statSync(fp).mtime.getTime() };
@@ -152,9 +152,9 @@ function handleRequest(req, res) {
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
res.end(html);
} else if (req.method === 'GET' && req.url.startsWith('/files/')) {
- const fileName = req.url.slice(7);
- const filePath = path.join(CONTENT_DIR, path.basename(fileName));
- if (!fs.existsSync(filePath)) {
+ const fileName = path.basename(req.url.slice(7));
+ const filePath = path.join(CONTENT_DIR, fileName);
+ if (fileName.startsWith('.') || !fs.existsSync(filePath)) {
res.writeHead(404);
res.end('Not found');
return;
@@ -276,14 +276,14 @@ function startServer() {
// macOS fs.watch reports 'rename' for both new files and overwrites,
// so we can't rely on eventType alone.
const knownFiles = new Set(
- fs.readdirSync(CONTENT_DIR).filter(f => f.endsWith('.html'))
+ fs.readdirSync(CONTENT_DIR).filter(f => !f.startsWith('.') && f.endsWith('.html'))
);
const server = http.createServer(handleRequest);
server.on('upgrade', handleUpgrade);
const watcher = fs.watch(CONTENT_DIR, (eventType, filename) => {
- if (!filename || !filename.endsWith('.html')) return;
+ if (!filename || filename.startsWith('.') || !filename.endsWith('.html')) return;
if (debounceTimers.has(filename)) clearTimeout(debounceTimers.get(filename));
debounceTimers.set(filename, setTimeout(() => {