prevent-link-loss - Handle two-dot diff (range) links#9696
Merged
fregante merged 1 commit intoJun 4, 2026
Conversation
PR commit/changes links of the form `/pull/N/changes/SHA1..SHA2` were only matched up to SHA1, leaving `..SHA2` outside the generated Markdown link. Extend `prCommitPathnameRegex` to optionally capture the second SHA and render it as `SHA1..SHA2` in the replacement.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this fixes
prevent-link-lossonly matched the first commit of a two-dot diff (range) link of the form/pull/N/changes/SHA1..SHA2, leaving..SHA2dangling outside the generated Markdown link.For example:
https://github.com/refined-github/refined-github/pull/6954/changes/32d1c8b2e1b6971709fe273cfdd1f959b51e8d85..5d28ba424368606c7b241840cf4386f23ce66ec3was converted to:
32d1c8b (#6954)..5d28ba424368606c7b241840cf4386f23ce66ec3It now produces the full range:
32d1c8b..5d28ba4 (#6954)prCommitPathnameRegexnow optionally captures the second SHA; single-commit links are unaffected (the group is optional). Unit tests added for the range form, idempotency, Markdown-link skipping, and the "this PR" branch.1. Related issue
No existing issue.
2. Pages affected/tested
Any comment field with a rich-text editor (issue/PR comments, reviews, PR body).
Disclosure: I asked Claude Opus 4.8 to fix the issue and write the tests, but did the rest (this PR description, etc.) manually.