Skip to content

Commit

Permalink
fix(path): handle lone slash (#1713)
Browse files Browse the repository at this point in the history
  • Loading branch information
aarnphm authored Jan 7, 2025
1 parent c90dbac commit 7e82825
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions quartz/util/path.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ describe("transforms", () => {
assert.strictEqual(path.joinSegments("/a", "b/"), "/a/b/")
assert.strictEqual(path.joinSegments("/a/", "b/"), "/a/b/")

// lone slash
assert.strictEqual(path.joinSegments("/a/", "b", "/"), "/a/b/")
assert.strictEqual(path.joinSegments("a/", "b" + "/"), "a/b/")

// works with protocol specifiers
assert.strictEqual(path.joinSegments("https://example.com", "a"), "https://example.com/a")
assert.strictEqual(path.joinSegments("https://example.com/", "a"), "https://example.com/a")
Expand Down
2 changes: 1 addition & 1 deletion quartz/util/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export function joinSegments(...args: string[]): string {
}

let joined = args
.filter((segment) => segment !== "")
.filter((segment) => segment !== "" && segment !== "/")
.map((segment) => stripSlashes(segment))
.join("/")

Expand Down

0 comments on commit 7e82825

Please sign in to comment.