Skip to content

Commit db30371

Browse files
committed
Don’t prepent relative path to web urls
Resolves #6943
1 parent 2887e3e commit db30371

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎src/project/types/website/listing/website-listing-shared.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,12 @@ export const renderedContentReader = (
278278
};
279279
};
280280

281+
const isWebUrl = (url: string) => {
282+
return url.startsWith("http:") || url.startsWith("https:");
283+
};
284+
281285
export const absoluteUrl = (siteUrl: string, url: string) => {
282-
if (url.startsWith("http:") || url.startsWith("https:")) {
286+
if (isWebUrl(url)) {
283287
return url;
284288
} else {
285289
const baseUrl = siteUrl.endsWith("/")
@@ -330,7 +334,7 @@ export function readRenderedContents(
330334
const imgEl = imgNode as Element;
331335
let src = imgEl.getAttribute("src");
332336
if (src) {
333-
if (!src.startsWith("/")) {
337+
if (!src.startsWith("/") && !isWebUrl(src)) {
334338
src = join(fileRelFolder, src);
335339
}
336340
imgEl.setAttribute("src", absoluteUrl(siteUrl, src));

0 commit comments

Comments
 (0)