mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 06:56:24 +00:00
feat: add git@ support to message github url method (#12899)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
This commit is contained in:
parent
c42faf0fec
commit
aba9a43543
2 changed files with 36 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
|||
import * as datasourceMaven from './maven';
|
||||
import { addMetaData } from './metadata';
|
||||
import { addMetaData, massageGithubUrl } from './metadata';
|
||||
import * as datasourceNpm from './npm';
|
||||
import { PypiDatasource } from './pypi';
|
||||
import type { ReleaseResult } from './types';
|
||||
|
@ -227,4 +227,30 @@ describe('datasource/metadata', () => {
|
|||
{ releaseTimestamp: '2000-01-03T12:34:56.000Z' },
|
||||
]);
|
||||
});
|
||||
|
||||
it('Should massage github git@ url to valid https url', () => {
|
||||
expect(massageGithubUrl('git@example.com:foo/bar')).toMatch(
|
||||
'https://example.com/foo/bar'
|
||||
);
|
||||
});
|
||||
it('Should massage github http url to valid https url', () => {
|
||||
expect(massageGithubUrl('http://example.com/foo/bar')).toMatch(
|
||||
'https://example.com/foo/bar'
|
||||
);
|
||||
});
|
||||
it('Should massage github http and git url to valid https url', () => {
|
||||
expect(massageGithubUrl('http+git://example.com/foo/bar')).toMatch(
|
||||
'https://example.com/foo/bar'
|
||||
);
|
||||
});
|
||||
it('Should massage github ssh git@ url to valid https url', () => {
|
||||
expect(massageGithubUrl('ssh://git@example.com/foo/bar')).toMatch(
|
||||
'https://example.com/foo/bar'
|
||||
);
|
||||
});
|
||||
it('Should massage github git url to valid https url', () => {
|
||||
expect(massageGithubUrl('git://example.com/foo/bar')).toMatch(
|
||||
'https://example.com/foo/bar'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -110,11 +110,18 @@ const manualSourceUrls = {
|
|||
const githubPages = regEx('^https://([^.]+).github.com/([^/]+)$');
|
||||
const gitPrefix = regEx('^git:/?/?');
|
||||
|
||||
function massageGithubUrl(url: string): string {
|
||||
return url
|
||||
export function massageGithubUrl(url: string): string {
|
||||
let massagedUrl = url;
|
||||
|
||||
if (url.startsWith('git@')) {
|
||||
massagedUrl = url.replace(':', '/').replace('git@', 'https://');
|
||||
}
|
||||
|
||||
return massagedUrl
|
||||
.replace('http:', 'https:')
|
||||
.replace('http+git:', 'https:')
|
||||
.replace('https+git:', 'https:')
|
||||
.replace('ssh://git@', 'https://')
|
||||
.replace(gitPrefix, 'https://')
|
||||
.replace(githubPages, 'https://github.com/$1/$2')
|
||||
.replace('www.github.com', 'github.com')
|
||||
|
|
Loading…
Reference in a new issue