14 lines
576 B
TypeScript
14 lines
576 B
TypeScript
import assert from 'node:assert/strict'
|
|
import test from 'node:test'
|
|
|
|
import { protectProviderImageSrcInHTML } from './security.ts'
|
|
|
|
test('protectProviderImageSrcInHTML uses a placeholder src for provider images', () => {
|
|
const html = '<p><img alt="preview" src="local://10000/exports/a.jpg"></p>'
|
|
const sanitized = protectProviderImageSrcInHTML(html)
|
|
const renderedSrc = sanitized.match(/<img[^>]*\ssrc="([^"]+)"/)?.[1]
|
|
|
|
assert.match(renderedSrc || '', /^data:image\/gif;base64,/)
|
|
assert.match(sanitized, /data-protected-src="local:\/\/10000\/exports\/a\.jpg"/)
|
|
})
|