Skip to content

Commit 67ff6ae

Browse files
committed
fix(web): keep the scheme lookbehind linear on hyphen runs
Dropping + and - from the lookbehind rescanned every token of an a-a-a… run (410 ms on a 20k-char line); one optional leading + or - keeps it linear.
1 parent 9160114 commit 67ff6ae

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ const TRAILING_PATH_PUNCTUATION_PATTERN = /[.,;:!?]+$/;
4242
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,
45-
// 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;
45+
// a diff's `+` or `-` may lead, and the lookbehind keeps runs from being rescanned at every suffix.
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)