Skip to content

Commit

Permalink
Properly join url for website meta
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonstyle committed Apr 29, 2022
1 parent 07f37b0 commit c4b0511
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/core/url.ts
Original file line number Diff line number Diff line change
@@ -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, "/");
}
3 changes: 2 additions & 1 deletion src/project/types/website/website-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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,
};
Expand Down

0 comments on commit c4b0511

Please sign in to comment.