diff options
Diffstat (limited to 'modules/test')
| -rw-r--r-- | modules/test/test-download-url.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/modules/test/test-download-url.js b/modules/test/test-download-url.js new file mode 100644 index 0000000..63cabde --- /dev/null +++ b/modules/test/test-download-url.js @@ -0,0 +1,32 @@ +// node modules/test/test-download-url.js +// Regression guard for the download/share URL space (2026-10-21). +// The URL must follow the WebDAV config (the logged-in user's space), NOT the +// page path — /spaces/newos4/ is the app, not the user. +const cases = [ + { page: '/spaces/newos4/', cfg: 'https://webx11.duckdns.org/spaces/agando/', want: 'agando' }, + { page: '/spaces/newos4/', cfg: 'https://webx11.duckdns.org/spaces/mindtech/', want: 'mindtech' }, + { page: '/spaces/agando/', cfg: 'https://webx11.duckdns.org/spaces/agando/', want: 'agando' }, + { page: '/spaces/newos4/', cfg: '', want: 'newos4' }, // no config → fall back to the page space +]; + +function detectSpaceName(path) { + const parts = path.split('/').filter(Boolean); + const i = parts.indexOf('spaces'); + return (i >= 0 && i + 1 < parts.length) ? parts[i + 1] : ''; +} +function extractSpaceNameFromUrl(url) { + if (!url) return ''; + const parts = new URL(url).pathname.split('/').filter(Boolean); + const i = parts.indexOf('spaces'); + return (i >= 0 && i + 1 < parts.length) ? parts[i + 1] : ''; +} + +let bad = 0; +for (const c of cases) { + const got = extractSpaceNameFromUrl(c.cfg) || detectSpaceName(c.page); + const ok = got === c.want; + if (!ok) bad++; + console.log((ok ? 'PASS' : 'FAIL'), c.page, 'cfg=' + (c.cfg || '(none)'), '→', got, '(want', c.want + ')'); +} +console.log(bad ? `\n${bad} FAILED` : `\n${cases.length} PASS`); +process.exit(bad ? 1 : 0); |