From c4b051106b84306415512eeca086746c4da75950 Mon Sep 17 00:00:00 2001 From: Charles Teague Date: Thu, 28 Apr 2022 21:19:36 -0400 Subject: [PATCH] Properly join url for website meta --- src/core/url.ts | 11 +++++++++++ src/project/types/website/website-meta.ts | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 src/core/url.ts diff --git a/src/core/url.ts b/src/core/url.ts new file mode 100644 index 0000000000..35f1625a31 --- /dev/null +++ b/src/core/url.ts @@ -0,0 +1,11 @@ +/* +* url.ts +* +* Copyright (C) 2020 by RStudio, PBC +* +*/ + +export function joinUrl(baseUrl: string, path: string) { + const joined = `${baseUrl}/${path}`; + return joined.replace(/\/\//g, "/"); +} diff --git a/src/project/types/website/website-meta.ts b/src/project/types/website/website-meta.ts index b87d952cb6..b12ad99771 100644 --- a/src/project/types/website/website-meta.ts +++ b/src/project/types/website/website-meta.ts @@ -44,6 +44,7 @@ import { import { HtmlPostProcessResult } from "../../../command/render/types.ts"; import { imageSize } from "../../../core/image.ts"; import { writeMetaTag } from "../../../format/html/format-html-shared.ts"; +import { joinUrl } from "../../../core/url.ts"; const kCard = "card"; @@ -333,7 +334,7 @@ function imageMetadata( // resolve the image path into an absolute href return { - href: `${baseUrl}/${imageProjectRelative}`, + href: joinUrl(baseUrl, imageProjectRelative), height: size?.height, width: size?.width, };