From 9c4203c8906ec9c2e9cf07d54b111ae73a1135f0 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek <tobias@bieniek.cloud> Date: Sat, 12 Sep 2020 14:15:40 +0200 Subject: [PATCH] chore(datasource/metadata): Move `massageGithub|GitLabUrl()` functions out of `addMetaData()` (#7264) --- lib/datasource/metadata.ts | 43 +++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/lib/datasource/metadata.ts b/lib/datasource/metadata.ts index b81603608d..406ab943fc 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 -- GitLab