Skip to content

Commit ca83d4d

Browse files
fix(mobile): file URL autolinks keep their file name chip
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent b523822 commit ca83d4d

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

‎apps/mobile/src/native/useEnrichedLinkVariants.test.tsx‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,10 @@ it("keeps the file name chip for an inline-code Windows path", async () => {
8686

8787
expect(content["C:\\repo\\src\\a.ts"]?.label).toBe("a.ts");
8888
});
89+
90+
it("keeps the file name chip for a file URL autolink", async () => {
91+
const url = "file:///home/me/docs/guide.md";
92+
const content = await pillContent([{ url, label: url, title: "" }]);
93+
94+
expect(content[url]?.label).toBe("guide.md");
95+
});

‎apps/mobile/src/native/useEnrichedLinkVariants.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@ function presentation(
8282
if (link.kind === "file")
8383
return {
8484
// Without a label the native pill shows the authored text, e.g. [the setup steps](docs/guide.md).
85-
// preserveWindowsPaths keeps backslash escapes in link text, so test the unescaped text too.
85+
// An autolink's text is its URL. preserveWindowsPaths keeps backslash escapes in link text.
8686
label: authoredLabels.every(
8787
(label) =>
88+
label === url ||
8889
isMarkdownFileLinkLabel(label, link.href) ||
8990
isMarkdownFileLinkLabel(label.replace(/\\(.)/g, "$1"), link.href),
9091
)

0 commit comments

Comments
 (0)