Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions apps/web/src/terminal-links.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,32 @@ describe("extractTerminalLinks", () => {
},
]);
});

it("finds Windows absolute paths with forward slashes", () => {
const line = "see C:/Users/someone/project/src/file.ts:42 for details";
const path = "C:/Users/someone/project/src/file.ts:42";
const start = line.indexOf(path);
expect(extractTerminalLinks(line)).toEqual([
{
kind: "path",
text: path,
start,
end: start + path.length,
},
]);
});

it("trims trailing punctuation from Windows forward-slash paths", () => {
const line = "(C:/tmp/x.ts).";
expect(extractTerminalLinks(line)).toEqual([
{
kind: "path",
text: "C:/tmp/x.ts",
start: 1,
end: 12,
},
]);
});
});

describe("resolvePathLinkTarget", () => {
Expand All @@ -60,6 +86,12 @@ describe("resolvePathLinkTarget", () => {
resolvePathLinkTarget("/Users/julius/project/src/main.ts:12", "/Users/julius/project"),
).toBe("/Users/julius/project/src/main.ts:12");
});

it("keeps Windows absolute paths with forward slashes unchanged", () => {
expect(
resolvePathLinkTarget("C:/Users/julius/project/src/main.ts:12", "C:\\Users\\julius\\project"),
).toBe("C:/Users/julius/project/src/main.ts:12");
});
});

describe("isTerminalLinkActivation", () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/terminal-links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface TerminalLinkMatch {

const URL_PATTERN = /https?:\/\/[^\s"'`<>]+/g;
const FILE_PATH_PATTERN =
/(?:~\/|\.{1,2}\/|\/|[A-Za-z]:\\|\\\\)[^\s"'`<>]+|[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)+(?::\d+){0,2}/g;
/(?:~\/|\.{1,2}\/|\/|[A-Za-z]:[\\/]|\\\\)[^\s"'`<>]+|[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)+(?::\d+){0,2}/g;
const TRAILING_PUNCTUATION_PATTERN = /[.,;!?]+$/;

function trimClosingDelimiters(value: string): string {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/wsTransport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ describe("WsTransport", () => {
expect(warnSpy).toHaveBeenNthCalledWith(
1,
"Dropped inbound WebSocket envelope",
"SyntaxError: Expected property name or '}' in JSON at position 2 (line 1 column 3)",
expect.stringMatching(/^SyntaxError:/),
);
expect(warnSpy).toHaveBeenNthCalledWith(
2,
Expand Down