Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): keep the final segment of directory paths with a trailing separator #5460

Mergedjorvarea(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/5460/headmerged by juliusmarminge View on GitHub

Showing 2 changed files with 31 additions and 2 deletions.

x
0 of 2 viewed, 2 left
25 additions and 0 deletionsapps/web/src/markdown-links.test.tsModified
View file
@@ -273,3 +273,28 @@
expect(resolveInlineCodeFileLinkMeta(".plans/worktree-management-v1.md")).toBeNull();
});
});
+​
+describe("directory paths with a trailing separator", () => {
+ it("keeps the final segment for a POSIX directory path", () => {
+ expect(resolveMarkdownFileLinkMeta("/tmp/favicons/", "/repo/project")).toMatchObject({
+ basename: "favicons",
+ });
+ });
+​
+ it("keeps the final segment for a Windows directory path", () => {
+ expect(
+ resolveMarkdownFileLinkMeta("C:\\Users\\kelchm\\.claude\\", "/repo/project"),
+ ).toMatchObject({ basename: ".claude" });
+ });
+​
+ it("matches the label of the same path without a trailing separator", () => {
+ const withSlash = resolveMarkdownFileLinkMeta("/tmp/favicons/", "/repo/project");
+ const withoutSlash = resolveMarkdownFileLinkMeta("/tmp/favicons", "/repo/project");
+ expect(withSlash?.basename).toBe(withoutSlash?.basename);
+ });
+​
+ it("does not produce an empty label for the filesystem root", () => {
+ const meta = resolveMarkdownFileLinkMeta("/tmp/", "/repo/project");
+ expect(meta?.basename).not.toBe("");
+ });
+});