Repository navigation
Fix prevent-pr-commit-link-loss - #3223
Merged
Merged
Conversation
This comment has been minimized.
This comment has been minimized.
This reverts commit 3e0cb4b.
fregante
marked this pull request as ready for review
June 13, 2020 17:59
fregante
marked this pull request as draft
June 13, 2020 18:09
I don't think it's possible to both look for an optional string and exclude whole strings that are followed by a paren, so I had to move that logic outside the regex
Member
Author
|
Successful test with |
FloEdelmann
reviewed
Jun 14, 2020
|
|
||
| const escapeRegex = (string: string) => string.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&'); | ||
| export const prCommitRegex = new RegExp(`\\b${escapeRegex(location.origin)}[/][^/]+[/][^/]+[/]pull[/]\\d+[/]commits[/][0-9a-f]{7,40}\\b(?! \\]|\\))`, 'gi'); | ||
| const prCommitPathnameRegex = /[/][^/]+[/][^/]+[/]pull[/](\d+)[/]commits[/]([\da-f]{7})[\da-f]{33}(?:#[\w-]+)?\b/; // eslint-disable-line unicorn/better-regex |
Member
There was a problem hiding this comment.
Why do you use [/] instead of \/?
Member
Author
There was a problem hiding this comment.
I generally find them easier to follow. Example, how long does it take to understand what this regex matches?
/^\/\/\*\??/[] equivalent
/^[/][/][*][?]?/
matches
'//*?' or '//*'
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.
Blinking message
Fixes #3085 (comment)
https://github.com/sindresorhus/refined-github/pull/3085/commits/a7b1a8bd85c230ff9ff8e407ca8f6d3646c90eb6in a fieldURLs with hashes
Fixes #3222
https://github.com/sindresorhus/refined-github/pull/3205/commits/1da152b3f8c51dd72d8ae6ad9cc96e0c2d8716f5#diff-932095cc3c0dff00495b4c392d78f0afR60in a fieldFix link#diff- etc ceterapartDebounces
This should avoid slowing down typing long comments (regardless of broken links)
Shorten URL
Since we're creating a custom link, we might as well make it look good for everyone
Paste
https://github.com/sindresorhus/refined-github/pull/3085/commits/a7b1a8bd85c230ff9ff8e407ca8f6d3646c90eb6in a fieldClick
Fix linkThe link should appear as
Note: the hash doesn't appear in this shortened version... but it's no biggie IMHO