import assert from 'node:assert/strict' import test from 'node:test' import { isPagePath } from '../app/utils/pagePath.ts' test('isPagePath: Nuxt, layer and API paths are skipped', () => { for (const p of ['/_nuxt/x', '/_nuxt/entry.js', '/__nuxt_error?url=/x', '/_seo/api/v1/resolve', '/_journal/api/v1/posts', '/api/x', '/api', '/api?x=1']) { assert.equal(isPagePath(p), false, p) } }) test('isPagePath: asset and root files are skipped', () => { for (const p of ['/favicon.ico', '/robots.txt', '/sitemap.xml', '/google0123.html', '/img/a.webp', '/fonts/x.woff2', '/blog/x/_payload.json', '/doc.pdf']) { assert.equal(isPagePath(p), false, p) } }) test('isPagePath: pages are resolved, with their query', () => { for (const p of ['/', '/blog/x', '/blog?page=2', '/autor/info@golem15.com', '/a.b/c', '/v1.2']) { assert.equal(isPagePath(p), true, p) } }) test('isPagePath: resolveFiles extensions are resolved', () => { assert.equal(isPagePath('/doc.pdf', ['pdf']), true) assert.equal(isPagePath('/DOC.PDF', ['pdf']), true) assert.equal(isPagePath('/a.png', ['pdf']), false) }) test('isPagePath: no protocol-relative or relative input', () => { for (const p of ['//evil.test/x', 'blog', '']) assert.equal(isPagePath(p), false, p) })