Skip to content

Commit 9160114

Browse files
committed
fix(web): also catch URLs right after a diff + or -
The lookbehind skipped a scheme preceded by + or -, so +redis://… in git diff output still linked s://….
1 parent be1a4a1 commit 9160114

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ describe("extractTerminalLinks", () => {
192192
"connected to postgres://localhost:5432/app",
193193
"uploaded s3://bucket/reports/today.csv",
194194
" at main (file:///Users/jane/app/src/index.mjs:3:7)",
195+
"+redis://localhost:6379/0",
196+
"-redis://localhost:6379/0",
195197
])("does not turn part of a non-web URL into an editor link: %s", (line) => {
196198
expect(extractTerminalLinks(line)).toEqual([]);
197199
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const REQUEST_ROUTE_PATTERN =
4343
/(?:^|[\s"'`])(?:GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS|CONNECT|TRACE|proxying)\s+["'`]?(?:\/|[A-Za-z0-9_-]+\/)[^\s?]*\?\S*/g;
4444
// The tail of `redis://host/0` or `file:///a.mjs` is not a path. One-letter schemes stay drives,
4545
// and the lookbehind keeps runs of letters from being rescanned at every suffix.
46-
const SCHEME_URL_PATTERN = /(?<![A-Za-z\d+.-])[A-Za-z][A-Za-z\d+.-]+:\/\/[^\s"'`<>]+/gu;
46+
const SCHEME_URL_PATTERN = /(?<![A-Za-z\d.])[A-Za-z][A-Za-z\d+.-]+:\/\/[^\s"'`<>]+/gu;
4747

4848
function trimClosingDelimiters(value: string, kind: TerminalLinkKind): string {
4949
let output = value.replace(

0 commit comments

Comments
 (0)