Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): terminal URLs like redis:// no longer become broken file links #25563

ClosedMarcoDotIO(GitHub profile, opens in a new tab)wants to merge 3 commits intomain fromrefs/pull/25563/headopened View on GitHub

Showing 2 changed files with 43 additions and 7 deletions.

x
0 of 2 viewed, 2 left
24 additions and 0 deletionsapps/web/src/terminal-links.test.tsModified
View file
@@ -157,6 +157,30 @@
]);
});
​
+ it.each([
+ "redis://127.0.0.1:6379/0",
+ "postgres://app:secret@db.internal:5432/app",
+ "mongodb://localhost:27017/test",
+ "ws://localhost:3000/socket",
+ "s3://bucket/reports/today.csv",
+ ])("does not turn part of %s into a file link", (url) => {
+ expect(extractTerminalLinks(`connected to ${url}`)).toEqual([]);
+ });
+​
+ it("keeps file links next to a non-web URL", () => {
+ const line = "src/db.ts:4 redis://localhost:6379/0 C:/app/src/db.ts:9";
+ expect(extractTerminalLinks(line)).toEqual([
+ { kind: "path", text: "src/db.ts:4", start: 0, end: 11 },
+ { kind: "path", text: "C:/app/src/db.ts:9", start: 37, end: 55 },
+ ]);
+ });
+​
+ it("does not link a mangled path out of a file URL", () => {
+ expect(extractTerminalLinks(" at main (file:///Users/jane/app/src/index.mjs:3:7)")).toEqual(
+ [],
+ );
+ });
+​
it("keeps a question mark inside a filesystem path", () => {
const path = "/tmp/report?draft";