mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 15:06:27 +00:00
chore(datasource/metadata): Move massageGithub|GitLabUrl()
functions out of addMetaData()
(#7264)
This commit is contained in:
parent
171b65eed0
commit
9c4203c890
1 changed files with 19 additions and 24 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue