Skip to content

Strip the inherited /null/ path prefix before route matching - #75

Merged
blixvip merged 1 commit into
blixvip:mainfrom
hussain-alsaibai:fix/null-prefix-order
Nov 16, 2026
Merged

blixvip merged 1 commit into
blixvip:mainfrom
hussain-alsaibai:fix/null-prefix-order

Conversation

@hussain-alsaibai

Copy link
Copy Markdown
Contributor

Summary

server.js rewrote /null and /null/... back onto the real routes, but the
rewrite sat at the end of the handler — after the / and /editor rewrites,
the readOnly JSON table, the template-source route and the /api/ guard had
already been skipped. The prefix therefore only ever reached serveFile, so
every inherited link 404'd.

The same ordering broke /null itself: pathname = '/' was assigned after
the '/' -> '/demo.html' rewrite had passed, so it fell through to the
directory index and served the template gallery instead of the homepage.

This moves the two lines to just after the pathname sanity checks, so every
later branch sees the already-stripped path. /null and /null/ normalize to
/ so they pick up the demo.html rewrite. The rest of the handler is
untouched.

Verification

Live createApp() before the change, as reported in the issue:

request before after
/null/health 404 200
/null/api/v1/templates 404 200
/null/api/references 404 200
/null/editor 404 200
/null/media/references/227b019e7968.mp4 404 200
/null title Template Gallery Null Motion
/null/ title Template Gallery Null Motion

Added inherited /null/ path prefix is stripped before route matching to
test/server.test.js, covering all five routes plus the demo.html vs
index.html title distinction. The test fails on origin/main and passes
with the change:

✖ inherited /null/ path prefix is stripped before route matching  (before)
✔ inherited /null/ path prefix is stripped before route matching  (after)

Full suite: 41 -> 42 tests, 40 pass / 2 fail. The two failures
(extractAudio reuses cached files..., reference audio route extracts missing audio once...) are pre-existing — the unmodified base commit fails the
same two, and the change does not touch audio extraction.

Closes #57

The alias rewrite lived at the end of the request handler, after the
`/` and `/editor` rewrites, the readOnly JSON table, the template-source
route and the `/api/` guard had all been skipped. A `/null/...` link
therefore only ever reached serveFile, so `/null/health`,
`/null/api/v1/templates`, `/null/api/references`, `/null/editor` and
`/null/media/references/*.mp4` all 404'd.

`/null` also assigned `pathname = '/'` after the `'/' -> '/demo.html'`
rewrite had already passed, so it fell through to the directory index and
served the template gallery instead of the homepage.

Move the two lines to just after the pathname sanity checks so every later
branch sees the stripped path, and normalize `/null` and `/null/` to `/`
so they pick up the demo.html rewrite.

Refs blixvip#57
@blixvip
blixvip merged commit 0b44f5a into blixvip:main Nov 16, 2026
1 check passed
@blixvip

blixvip commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Merged, thanks @hussain-alsaibai! Locally npm test passes 42/42 and npm run check is clean. Your new test fails on the old code (/null/health, /null/api/... and /null/editor all missed their routes) and passes with the fix. Moving the strip ahead of every route, and normalizing /null/ to / so it reaches demo.html instead of the directory index, was the right call. #57 is closed.

If you'd like another, #68 (keep the preview Play/Pause button label in sync with the film) is a small UI-state fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Strip the inherited /null/ path prefix before the API, media and page routes

2 participants