Skip to content

Commit 0f58531

Browse files
committed
fix(mobile): recognize inline file link line ranges
1 parent 63f31b1 commit 0f58531

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

‎apps/mobile/src/lib/enrichedLinkPresentation.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export function enrichedLinkVariantPattern(url: string) {
8888
}
8989

9090
export const ENRICHED_INLINE_FILE_LINK_REGEX =
91-
/^(?!\S*:\/\/)(?:(?:\.{1,2}[\\/]|~[\\/]|\/(?:Users|home|tmp|var|etc|opt|mnt|Volumes|private|root|usr|bin|sbin|lib|lib64|srv|dev|proc|sys|run|boot|media|workspace|workspaces)\/|[A-Za-z]:[\\/])[^\s`]+|(?:[A-Za-z0-9._-]+[\\/])+[A-Za-z0-9._-]+\.[A-Za-z0-9_-]+(?::\d+){0,2}|[A-Za-z0-9._-]+\.[A-Za-z0-9_-]+:\d+(?::\d+)?)$/;
91+
/^(?!\S*:\/\/)(?:(?:\.{1,2}[\\/]|~[\\/]|\/(?:Users|home|tmp|var|etc|opt|mnt|Volumes|private|root|usr|bin|sbin|lib|lib64|srv|dev|proc|sys|run|boot|media|workspace|workspaces)\/|[A-Za-z]:[\\/])[^\s`]+|(?:[A-Za-z0-9._-]+[\\/])+[A-Za-z0-9._-]+\.[A-Za-z0-9_-]+(?::\d+(?:-\d+|:\d+)?)?|[A-Za-z0-9._-]+\.[A-Za-z0-9_-]+:\d+(?::\d+|-\d+)?)$/;
9292

9393
export function enrichedSkillLinkRegex(skills?: ReadonlyArray<SelectableMarkdownSkill>) {
9494
const names = [...new Set(skills?.map((skill) => skill.name) ?? [])].filter(Boolean);

‎apps/mobile/src/lib/markdownInlineFileLinks.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ describe("inline code that names a file", () => {
7272
expect(rewrite("See `src/math.ts:2` and `./README.md`.")).toBe(
7373
"See [src/math.ts:2](<src/math.ts:2>) and [./README.md](<./README.md>).",
7474
);
75+
expect(rewrite("See `src/math.ts:2-4` and `math.ts:2-4`.")).toBe(
76+
"See [src/math.ts:2-4](<src/math.ts:2-4>) and [math.ts:2-4](<math.ts:2-4>).",
77+
);
7578
});
7679

7780
it("keeps commands, identifiers and URLs as code", () => {

0 commit comments

Comments
 (0)