fix(web): linkify Windows C:/ paths in terminal output (#1483)
This commit is contained in:
1 parent
80a176fe1f
commit
48196e67a7
3 files changed
+34
-2
No files matched your search
@@ -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", () => {
|
||||
@@ -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", () => {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user