Skip to content
Snippets Groups Projects
Unverified Commit 9c4203c8 authored by Tobias Bieniek's avatar Tobias Bieniek Committed by GitHub
Browse files

chore(datasource/metadata): Move `massageGithub|GitLabUrl()` functions out of...

chore(datasource/metadata): Move `massageGithub|GitLabUrl()` functions out of `addMetaData()` (#7264)
parent 171b65ee
No related branches found
No related tags found
No related merge requests found
...@@ -76,6 +76,25 @@ const manualSourceUrls = { ...@@ -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 */ /* eslint-disable no-param-reassign */
export function addMetaData( export function addMetaData(
dep?: ReleaseResult, dep?: ReleaseResult,
...@@ -93,30 +112,6 @@ export function addMetaData( ...@@ -93,30 +112,6 @@ export function addMetaData(
dep.sourceUrl = manualSourceUrls[datasource][lookupNameLowercase]; 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 ( if (
dep.changelogUrl?.includes('github.com') && // lgtm [js/incomplete-url-substring-sanitization] dep.changelogUrl?.includes('github.com') && // lgtm [js/incomplete-url-substring-sanitization]
!dep.sourceUrl !dep.sourceUrl
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment