import { test } from 'node:test'; import assert from 'node:assert/strict'; import { staticPath } from './static.ts'; test('static paths stay inside the web root', () => { const root = '/srv/dist/web'; assert.equal(staticPath(root, '/'), '/srv/dist/web/index.html'); assert.equal(staticPath(root, '/assets/app.js'), '/srv/dist/web/assets/app.js'); assert.equal(staticPath(root, '/../webx/secret'), '/srv/dist/web/webx/secret'); assert.equal(staticPath(root, '..%2Fwebx/secret'), null); assert.equal(staticPath(root, '/%2e%2e/%2e%2e/etc/passwd'), '/srv/dist/web/etc/passwd'); assert.equal(staticPath(root, '/bad%zz'), null); assert.equal(staticPath(root, '/a%00b'), null); });