From f66cc7266324ac07d2a952e922aba6453396670f Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 15 Jun 2025 14:10:35 -0300 Subject: replacer: complain about /media/ --- src/replacer.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'src/replacer.js') diff --git a/src/replacer.js b/src/replacer.js index 9d6fd191..c6aef6ef 100644 --- a/src/replacer.js +++ b/src/replacer.js @@ -635,16 +635,23 @@ function postprocessHTMLTags(inputNodes, tagName, callback) { return outputNodes; } +function complainAboutMediaSrc(src) { + if (!src) { + throw new Error(`Missing "src" attribute`); + } + + if (src.startsWith('/media/')) { + throw new Error(`Start "src" with "media/", not "/media/"`); + } +} + export function postprocessImages(inputNodes) { return postprocessHTMLTags(inputNodes, 'img', (attributes, {inline}) => { const node = {type: 'image'}; node.src = attributes.get('src'); - - if (!node.src) { - throw new Error(' missing src attribute'); - } + complainAboutMediaSrc(node.src); node.inline = attributes.get('inline') ?? inline; @@ -670,10 +677,7 @@ export function postprocessVideos(inputNodes) { const node = {type: 'video'}; node.src = attributes.get('src'); - - if (!node.src) { - throw new Error('