From 2eb9ecd34f89b82366ea84f991ec181939a0d8b2 Mon Sep 17 00:00:00 2001 From: Justyn Shull Date: Wed, 13 Mar 2024 02:26:40 -0500 Subject: [PATCH] Only prepend attachmentUrlPrefix if url doesnt already start with it (#800) --- plugs/markdown/markdown_render.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/plugs/markdown/markdown_render.ts b/plugs/markdown/markdown_render.ts index cc553971..d2f9c880 100644 --- a/plugs/markdown/markdown_render.ts +++ b/plugs/markdown/markdown_render.ts @@ -210,7 +210,12 @@ function render( } let url = urlNode.children![0].text!; if (url.indexOf("://") === -1) { - url = `${options.attachmentUrlPrefix || ""}${url}`; + if ( + options.attachmentUrlPrefix && + !url.startsWith(options.attachmentUrlPrefix) + ) { + url = `${options.attachmentUrlPrefix}${url}`; + } } return { name: "a", @@ -228,7 +233,12 @@ function render( } let url = urlNode!.children![0].text!; if (url.indexOf("://") === -1) { - url = `${options.attachmentUrlPrefix || ""}${url}`; + if ( + options.attachmentUrlPrefix && + !url.startsWith(options.attachmentUrlPrefix) + ) { + url = `${options.attachmentUrlPrefix}${url}`; + } } return { name: "img",