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

pull/770/head^2
Justyn Shull 2024-03-13 02:26:40 -05:00 committed by GitHub
parent 221e9e859c
commit 2eb9ecd34f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 2 deletions

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",