fix(github): don't match org name with underscore (#19071)

This commit is contained in:
Philip 2022-11-28 11:33:49 +02:00 committed by GitHub
parent e82f6cd480
commit 4f71562e56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View file

@ -63,6 +63,7 @@ describe('modules/platform/github/massage-markdown-links', () => {
${'github.com/foo/bar/issues/1'} | ${'[github.com/foo/bar/issues/1](togithub.com/foo/bar/issues/1)'}
${'github.com/foo/bar/pull/1'} | ${'[github.com/foo/bar/pull/1](togithub.com/foo/bar/pull/1)'}
${'github.com/Foo/bar/pull/1'} | ${'[github.com/Foo/bar/pull/1](togithub.com/Foo/bar/pull/1)'}
${'www.github.com/foo/bar.foo/pull/1'} | ${'[www.github.com/foo/bar.foo/pull/1](www.togithub.com/foo/bar.foo/pull/1)'}
${'www.github.com/foo/bar/discussions/1'} | ${'[www.github.com/foo/bar/discussions/1](www.togithub.com/foo/bar/discussions/1)'}
${'www.github.com/foo/bar/issues/1'} | ${'[www.github.com/foo/bar/issues/1](www.togithub.com/foo/bar/issues/1)'}
${'www.github.com/foo/bar/pull/1'} | ${'[www.github.com/foo/bar/pull/1](www.togithub.com/foo/bar/pull/1)'}
@ -77,6 +78,7 @@ describe('modules/platform/github/massage-markdown-links', () => {
${'[github.com/foo/bar/pull/1](github.com/foo/bar/pull/1)'} | ${'[github.com/foo/bar/pull/1](togithub.com/foo/bar/pull/1)'}
${'[www.github.com/foo/bar/discussions/1](www.github.com/foo/bar/discussions/1)'} | ${'[www.github.com/foo/bar/discussions/1](www.togithub.com/foo/bar/discussions/1)'}
${'[www.github.com/foo/bar/issues/1](www.github.com/foo/bar/issues/1)'} | ${'[www.github.com/foo/bar/issues/1](www.togithub.com/foo/bar/issues/1)'}
${'[www.github.com/foo/bar.foo/pull/1](www.github.com/foo/bar.foo/pull/1)'} | ${'[www.github.com/foo/bar.foo/pull/1](www.togithub.com/foo/bar.foo/pull/1)'}
${'[www.github.com/foo/bar/pull/1](www.github.com/foo/bar/pull/1)'} | ${'[www.github.com/foo/bar/pull/1](www.togithub.com/foo/bar/pull/1)'}
${'[https://github.com/foo/bar/discussions/1](https://github.com/foo/bar/discussions/1)'} | ${'[https://github.com/foo/bar/discussions/1](https://togithub.com/foo/bar/discussions/1)'}
${'[https://github.com/foo/bar/issues/1](https://github.com/foo/bar/issues/1)'} | ${'[https://github.com/foo/bar/issues/1](https://togithub.com/foo/bar/issues/1)'}

View file

@ -10,8 +10,9 @@ interface UrlMatch {
replaceTo: string;
}
//according to https://github.com/dead-claudia/github-limits
const urlRegex =
/(?:https?:)?(?:\/\/)?(?:www\.)?(?<!api\.)(?:to)?github\.com\/[-_a-z0-9]+\/[-_a-z0-9.]+\/(?:discussions|issues|pull)\/[0-9]+(?:#[-_a-z0-9]+)?/i; // TODO #12872 (?<!re) after text not matching
/(?:https?:)?(?:\/\/)?(?:www\.)?(?<!api\.)(?:to)?github\.com\/[-a-z0-9]+\/[-_a-z0-9.]+\/(?:discussions|issues|pull)\/[0-9]+(?:#[-_a-z0-9]+)?/i; // TODO #12872 (?<!re) after text not matching
function massageLink(input: string): string {
return input.replace(regEx(/(?:to)?github\.com/i), 'togithub.com');