Skip to content

Commit f0c1da3

Browse files
fix(github): long period runs no longer freeze reference autolinking (#26177)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 80b7b0f commit f0c1da3

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎packages/source-control-github/src/shared/referenceAutolinks.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@ describe("gitHubReferenceAutolinks", () => {
3636
);
3737
});
3838

39+
it("scans long runs of periods and dashes in linear time", () => {
40+
expect(linked(`${".".repeat(50_000)} ${".-".repeat(25_000)} #1`)).toEqual([
41+
["#1", "https://github.com/team/repo/issues/1", "reference"],
42+
]);
43+
});
44+
45+
it("links references that follow punctuation", () => {
46+
expect(linked("(#5), owner.name/repo-x#3")).toEqual([
47+
["#5", "https://github.com/team/repo/issues/5", "reference"],
48+
["owner.name/repo-x#3", "https://github.com/owner.name/repo-x/issues/3", "reference"],
49+
]);
50+
});
51+
3952
it("links against the repository's own host", () => {
4053
expect(
4154
gitHubReferenceAutolinks("See #5", "https://ghe.example.com/acme/web").map(({ url }) => url),

‎packages/source-control-github/src/shared/referenceAutolinks.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { ReferenceAutolink } from "@t3tools/source-control-core/shared/defi
33
// GitHub's autolinked references: `#12`, `repo#12` and `owner/repo#12`; a SHA of 7 to 40
44
// characters, optionally `repo@` or `owner/repo@` qualified; `@user` and `@org/team`.
55
const REFERENCE =
6-
/(?<![\w/\\])(?:([\w.-]+\/[\w.-]+|[\w-]+)?#([1-9]\d*)|(?:([\w.-]+\/[\w.-]+|[\w-]+)@)?([a-f\d]{7,40})(?![\w])|@([a-z\d](?:[a-z\d-]*[a-z\d])?(?:\/[a-z\d][a-z\d-]*)?))(?![\w])/giu;
6+
/(?<![\w./\\-])(?:([\w.-]+\/[\w.-]+|[\w-]+)?#([1-9]\d*)|(?:([\w.-]+\/[\w.-]+|[\w-]+)@)?([a-f\d]{7,40})(?![\w])|@([a-z\d](?:[a-z\d-]*[a-z\d])?(?:\/[a-z\d][a-z\d-]*)?))(?![\w])/giu;
77
const CANDIDATE = /[#@]|\b[a-f\d]{7,40}\b/iu;
88
const SHORT_SHA_LENGTH = 7;
99

0 commit comments

Comments
 (0)