diff --git a/lib/datasource/metadata.ts b/lib/datasource/metadata.ts index b81603608d5cdfc8703c3d17c727e125d98d6953..406ab943fc48e718e9687676a9dcbf8e748e5815 100644 --- a/lib/datasource/metadata.ts +++ b/lib/datasource/metadata.ts @@ -76,6 +76,25 @@ const manualSourceUrls = { }, }; +function massageGithubUrl(url: string): string { + return url + .replace('http:', 'https:') + .replace(/^git:\/?\/?/, 'https://') + .replace('www.github.com', 'github.com') + .split('/') + .slice(0, 5) + .join('/'); +} + +function massageGitlabUrl(url: string): string { + return url + .replace('http:', 'https:') + .replace(/^git:\/?\/?/, 'https://') + .replace(/\/tree\/.*$/i, '') + .replace(/\/$/i, '') + .replace('.git', ''); +} + /* eslint-disable no-param-reassign */ export function addMetaData( dep?: ReleaseResult, @@ -93,30 +112,6 @@ export function addMetaData( dep.sourceUrl = manualSourceUrls[datasource][lookupNameLowercase]; } - /** - * @param {string} url - */ - const massageGithubUrl = (url: string): string => { - return url - .replace('http:', 'https:') - .replace(/^git:\/?\/?/, 'https://') - .replace('www.github.com', 'github.com') - .split('/') - .slice(0, 5) - .join('/'); - }; - /** - * @param {string} url - */ - const massageGitlabUrl = (url: string): string => { - return url - .replace('http:', 'https:') - .replace(/^git:\/?\/?/, 'https://') - .replace(/\/tree\/.*$/i, '') - .replace(/\/$/i, '') - .replace('.git', ''); - }; - if ( dep.changelogUrl?.includes('github.com') && // lgtm [js/incomplete-url-substring-sanitization] !dep.sourceUrl