Skip to content

Commit 29f0bdd

Browse files
committed
fix(web): terminal links keep Unicode file paths intact
1 parent 42da166 commit 29f0bdd

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

‎apps/web/src/terminal-links.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,20 @@ describe("extractTerminalLinks", () => {
7272
]);
7373
});
7474

75+
it.each([
76+
"src/żółć.ts:12:7",
77+
"żółć/main.ts:12",
78+
"src/日本語.ts:12",
79+
"src/cafe\u0301.ts:12",
80+
"src/𐐀.ts:12",
81+
])("keeps the complete Unicode relative path in %s", (path) => {
82+
const line = `see ${path} for details`;
83+
const start = line.indexOf(path);
84+
const matches = extractTerminalLinks(line);
85+
expect(matches).toEqual([{ kind: "path", text: path, start, end: start + path.length }]);
86+
expect(resolvePathLinkTarget(matches[0]!.text, "/tmp/project")).toBe(`/tmp/project/${path}`);
87+
});
88+
7589
it("finds Windows absolute paths with forward slashes", () => {
7690
const line = "see C:/Users/someone/project/src/file.ts:42 for details";
7791
const path = "C:/Users/someone/project/src/file.ts:42";

‎apps/web/src/terminal-links.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export interface WrappedTerminalLinkLine {
2828

2929
const URL_PATTERN = /https?:\/\/[^\s"'`<>]+/giu;
3030
const FILE_PATH_PATTERN =
31-
/(?:~\/|\.{1,2}\/|\/|[A-Za-z]:[\\/]|\\\\)[^\s"'`<>]+|[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)+(?::\d+){0,2}/g;
31+
/(?:~\/|\.{1,2}\/|\/|[A-Za-z]:[\\/]|\\\\)[^\s"'`<>]+|[\p{L}\p{M}\p{N}._-]+(?:\/[\p{L}\p{M}\p{N}._-]+)+(?::\d+){0,2}/gu;
3232
const TRAILING_PUNCTUATION_PATTERN = /[.,;!?]+$/;
3333
// Paths also drop a trailing colon: compilers end `file:line:col:` with one.
3434
const TRAILING_PATH_PUNCTUATION_PATTERN = /[.,;:!?]+$/;

0 commit comments

Comments
 (0)