import assert from 'node:assert/strict'; import { test } from 'node:test'; import { escapeHtml, html, raw } from '../src/render/html.ts'; import { linkify } from '../src/render/text.ts'; import { renderPost } from '../src/render/post.ts'; import { renderError } from '../src/render/error.ts'; import { oneSegment, type Media, type Post } from '../src/types.ts'; test('interpolations are escaped, Raw values are not', () => { assert.equal(html`
${''}
`.value, '<script>alert(1)</script>
'); assert.equal(html`${raw('ok')}
`.value, 'ok
'); assert.equal(html`${['a', '']}`.value, 'a<b>'); assert.equal(html`${undefined}${null}${false}`.value, ''); }); test('attribute-breaking characters are escaped', () => { assert.equal(escapeHtml(`" onload='x'`), '" onload='x''); }); test('post text is escaped before links are made', () => { const out = linkify('