From 9466c145b1b84299be5f865596b3ebdac248b9fa Mon Sep 17 00:00:00 2001 From: moexiami <1927254+Xiami2012@users.noreply.github.com> Date: Thu, 2 Jan 2025 02:07:59 +0800 Subject: [PATCH] fix(path): correct handle URI schemes in joinSegments (#1693) --- quartz/util/path.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/quartz/util/path.ts b/quartz/util/path.ts index a6a05f9..d2409e1 100644 --- a/quartz/util/path.ts +++ b/quartz/util/path.ts @@ -185,8 +185,13 @@ export function slugTag(tag: string) { export function joinSegments(...args: string[]): string { return args .filter((segment) => segment !== "") + .map((segment, index) => + index === 0 + ? // Deduplicate but not remove leading slashes for first segment + segment.replace(/\/+$/g, "").replace(/^\/\/+/g, "/") + : segment.replace(/^\/+|\/+$/g, ""), + ) .join("/") - .replace(/\/\/+/g, "/") } export function getAllSegmentPrefixes(tags: string): string[] {