diff --git a/lib/modules/platform/github/__snapshots__/index.spec.ts.snap b/lib/modules/platform/github/__snapshots__/index.spec.ts.snap index 96af4722583653..fbd183bcf69668 100644 --- a/lib/modules/platform/github/__snapshots__/index.spec.ts.snap +++ b/lib/modules/platform/github/__snapshots__/index.spec.ts.snap @@ -119,4 +119,4 @@ exports[`modules/platform/github/index initRepo should update fork when using fo } `; -exports[`modules/platform/github/index massageMarkdown(input) returns updated pr body 1`] = `"[https://github.com/foo/bar/issues/5](https://togithub.com/foo/bar/issues/5) plus also [a link](https://togithub.com/foo/bar/issues/5)"`; +exports[`modules/platform/github/index massageMarkdown(input) returns updated pr body 1`] = `"[https://github.com/foo/bar/issues/5](https://redirect.github.com/foo/bar/issues/5) plus also [a link](https://redirect.github.com/foo/bar/issues/5)"`; diff --git a/lib/modules/platform/github/index.ts b/lib/modules/platform/github/index.ts index 2acbfa34503b22..23a8210574053a 100644 --- a/lib/modules/platform/github/index.ts +++ b/lib/modules/platform/github/index.ts @@ -1944,13 +1944,19 @@ export function massageMarkdown(input: string): string { return smartTruncate(input, maxBodyLength()); } const massagedInput = massageMarkdownLinks(input) - // to be safe, replace all github.com links with renovatebot redirector + // to be safe, replace all github.com links with redirect.github.com .replace( regEx(/href="https?:\/\/github.com\//g), - 'href="https://togithub.com/', + 'href="https://redirect.github.com/', + ) + .replace( + regEx(/]\(https:\/\/github\.com\//g), + '](https://redirect.github.com/', + ) + .replace( + regEx(/]: https:\/\/github\.com\//g), + ']: https://redirect.github.com/', ) - .replace(regEx(/]\(https:\/\/github\.com\//g), '](https://togithub.com/') - .replace(regEx(/]: https:\/\/github\.com\//g), ']: https://togithub.com/') .replace('> ℹ **Note**\n> \n', '> [!NOTE]\n') .replace('> ⚠ **Warning**\n> \n', '> [!WARNING]\n') .replace('> ⚠️ **Warning**\n> \n', '> [!WARNING]\n') diff --git a/lib/modules/platform/github/massage-markdown-links.spec.ts b/lib/modules/platform/github/massage-markdown-links.spec.ts index c8faf90feae990..b6ab2327f85fc2 100644 --- a/lib/modules/platform/github/massage-markdown-links.spec.ts +++ b/lib/modules/platform/github/massage-markdown-links.spec.ts @@ -9,8 +9,8 @@ describe('modules/platform/github/massage-markdown-links', () => { const res = massageMarkdownLinks(input); expect(res).toEqual( [ - 'Link [foo/bar#1](https://togithub.com/foo/bar/pull/1) points to [https://github.com/foo/bar/pull/1](https://togithub.com/foo/bar/pull/1).', - 'URL [https://github.com/foo/bar/pull/1](https://togithub.com/foo/bar/pull/1) becomes [foo/bar#1](https://togithub.com/foo/bar/pull/1).', + 'Link [foo/bar#1](https://redirect.github.com/foo/bar/pull/1) points to [https://github.com/foo/bar/pull/1](https://redirect.github.com/foo/bar/pull/1).', + 'URL [https://github.com/foo/bar/pull/1](https://redirect.github.com/foo/bar/pull/1) becomes [foo/bar#1](https://redirect.github.com/foo/bar/pull/1).', ].join('\n'), ); }); @@ -45,10 +45,10 @@ describe('modules/platform/github/massage-markdown-links', () => { ${'https://github.com/foo/bar/issues/'} ${'https://github.com/foo/bar/pull/'} ${'api.github.com'} - ${'togithub.com'} - ${'www.togithub.com'} - ${'https://togithub.com/foo/bar/releases/tag/v0.20.3'} - ${'https://togithub.com/foo/bar/compare/v0.20.2...v0.20.3'} + ${'redirect.github.com'} + ${'www.redirect.github.com'} + ${'https://redirect.github.com/foo/bar/releases/tag/v0.20.3'} + ${'https://redirect.github.com/foo/bar/compare/v0.20.2...v0.20.3'} `('Unchanged: $input', ({ input }: { input: string }) => { const inputText = `Foo ${input}, bar.`; expect(massageMarkdownLinks(inputText)).toEqual(inputText); @@ -59,30 +59,30 @@ describe('modules/platform/github/massage-markdown-links', () => { it.each` input | output - ${'github.com/foo/bar/discussions/1'} | ${'[github.com/foo/bar/discussions/1](togithub.com/foo/bar/discussions/1)'} - ${'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)'} - ${'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://togithub.com/foo/bar/issues/1)'} - ${'https://github.com/foo/bar/pull/1'} | ${'[https://github.com/foo/bar/pull/1](https://togithub.com/foo/bar/pull/1)'} - ${'https://github.com/foo/bar/discussions/1#comment-123'} | ${'[https://github.com/foo/bar/discussions/1#comment-123](https://togithub.com/foo/bar/discussions/1#comment-123)'} - ${'https://github.com/foo/bar/issues/1#comment-123'} | ${'[https://github.com/foo/bar/issues/1#comment-123](https://togithub.com/foo/bar/issues/1#comment-123)'} - ${'https://github.com/foo/bar/pull/1#comment-123'} | ${'[https://github.com/foo/bar/pull/1#comment-123](https://togithub.com/foo/bar/pull/1#comment-123)'} - ${'[github.com/foo/bar/discussions/1](github.com/foo/bar/discussions/1)'} | ${'[github.com/foo/bar/discussions/1](togithub.com/foo/bar/discussions/1)'} - ${'[github.com/foo/bar/issues/1](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)'} | ${'[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)'} - ${'[https://github.com/foo/bar/pull/1](https://github.com/foo/bar/pull/1)'} | ${'[https://github.com/foo/bar/pull/1](https://togithub.com/foo/bar/pull/1)'} + ${'github.com/foo/bar/discussions/1'} | ${'[github.com/foo/bar/discussions/1](redirect.github.com/foo/bar/discussions/1)'} + ${'github.com/foo/bar/issues/1'} | ${'[github.com/foo/bar/issues/1](redirect.github.com/foo/bar/issues/1)'} + ${'github.com/foo/bar/pull/1'} | ${'[github.com/foo/bar/pull/1](redirect.github.com/foo/bar/pull/1)'} + ${'github.com/Foo/bar/pull/1'} | ${'[github.com/Foo/bar/pull/1](redirect.github.com/Foo/bar/pull/1)'} + ${'www.github.com/foo/bar.foo/pull/1'} | ${'[www.github.com/foo/bar.foo/pull/1](redirect.github.com/foo/bar.foo/pull/1)'} + ${'www.github.com/foo/bar/discussions/1'} | ${'[www.github.com/foo/bar/discussions/1](redirect.github.com/foo/bar/discussions/1)'} + ${'www.github.com/foo/bar/issues/1'} | ${'[www.github.com/foo/bar/issues/1](redirect.github.com/foo/bar/issues/1)'} + ${'www.github.com/foo/bar/pull/1'} | ${'[www.github.com/foo/bar/pull/1](redirect.github.com/foo/bar/pull/1)'} + ${'https://github.com/foo/bar/discussions/1'} | ${'[https://github.com/foo/bar/discussions/1](https://redirect.github.com/foo/bar/discussions/1)'} + ${'https://github.com/foo/bar/issues/1'} | ${'[https://github.com/foo/bar/issues/1](https://redirect.github.com/foo/bar/issues/1)'} + ${'https://github.com/foo/bar/pull/1'} | ${'[https://github.com/foo/bar/pull/1](https://redirect.github.com/foo/bar/pull/1)'} + ${'https://github.com/foo/bar/discussions/1#comment-123'} | ${'[https://github.com/foo/bar/discussions/1#comment-123](https://redirect.github.com/foo/bar/discussions/1#comment-123)'} + ${'https://github.com/foo/bar/issues/1#comment-123'} | ${'[https://github.com/foo/bar/issues/1#comment-123](https://redirect.github.com/foo/bar/issues/1#comment-123)'} + ${'https://github.com/foo/bar/pull/1#comment-123'} | ${'[https://github.com/foo/bar/pull/1#comment-123](https://redirect.github.com/foo/bar/pull/1#comment-123)'} + ${'[github.com/foo/bar/discussions/1](github.com/foo/bar/discussions/1)'} | ${'[github.com/foo/bar/discussions/1](redirect.github.com/foo/bar/discussions/1)'} + ${'[github.com/foo/bar/issues/1](github.com/foo/bar/issues/1)'} | ${'[github.com/foo/bar/issues/1](redirect.github.com/foo/bar/issues/1)'} + ${'[github.com/foo/bar/pull/1](github.com/foo/bar/pull/1)'} | ${'[github.com/foo/bar/pull/1](redirect.github.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](redirect.github.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](redirect.github.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](redirect.github.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](redirect.github.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://redirect.github.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://redirect.github.com/foo/bar/issues/1)'} + ${'[https://github.com/foo/bar/pull/1](https://github.com/foo/bar/pull/1)'} | ${'[https://github.com/foo/bar/pull/1](https://redirect.github.com/foo/bar/pull/1)'} `( '$input -> $output', ({ input, output }: { input: string; output: string }) => { diff --git a/lib/modules/platform/github/massage-markdown-links.ts b/lib/modules/platform/github/massage-markdown-links.ts index 44c3b53616c6a6..80a4fd172569c4 100644 --- a/lib/modules/platform/github/massage-markdown-links.ts +++ b/lib/modules/platform/github/massage-markdown-links.ts @@ -16,7 +16,10 @@ const urlRegex = /(?:https?:)?(?:\/\/)?(?:www\.)?(?