Refined-github: Support compare diff URLs in `prevent-pr-commit-link-loss`

Created on 4 Sep 2020  路  6Comments  路  Source: sindresorhus/refined-github

Copy-paste this URL in a comment a click "Preview"

https://github.com/sindresorhus/got/compare/v11.5.2...v11.6.0#diff-6be2971b2bb8dbf48d15ff680dd898b0R191

GitHub changes the URL to the following, breaking it

https://github.com/sindresorhus/got/compare/v11.5.2...v11.6.0diff-6be2971b2bb8dbf48d15ff680dd898b0R191

This is a similar GitHub bug to https://github.com/sindresorhus/refined-github/issues/2327, which was fixed by https://github.com/sindresorhus/refined-github/pull/3085 (prevent-pr-commit-link-loss), so it'd make sense to extend that feature

enhancement help wanted

All 6 comments

can I work on this issue?

@esakki-selvaraj go for it!

@yakov116 Can i get some more links so that I can check my Reg Expression!

Keep in mind that there's a pretty advanced regex (which avoids selecting the url twice) already set up:

https://github.com/sindresorhus/refined-github/blob/6d339762d762b669bb48b2977f40a83c48305a2d/source/github-helpers/index.ts#L98-L99

And tested:

https://github.com/sindresorhus/refined-github/blob/86529e79015ea54b2eda9f06a1aca692acf7baea/test/helpers.ts#L176-L211

You should start from that regex: copy the regex, copy the tests (changing only the URLs) and make sure they pass.

it's working

Was this page helpful?
0 / 5 - 0 ratings