Only prepend attachmentUrlPrefix if url doesnt already start with it (#800)

This commit is contained in:
Justyn Shull
2024-03-13 08:26:40 +01:00
committed by GitHub
parent 221e9e859c
commit 2eb9ecd34f
+12 -2
View File
@@ -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",