fix(datasource): massage github sourceUrl if present

This commit is contained in:
Rhys Arkins 2019-04-20 10:32:12 +02:00
parent 3ba6d79458
commit 2e7e36bb5a
2 changed files with 14 additions and 0 deletions

View file

@ -1,4 +1,5 @@
const is = require('@sindresorhus/is'); const is = require('@sindresorhus/is');
const parse = require('github-url-from-git');
module.exports = { module.exports = {
addMetaData, addMetaData,
@ -78,6 +79,9 @@ function addMetaData(dep, datasource, lookupName) {
if (manualSourceUrls[datasource] && manualSourceUrls[datasource][depName]) { if (manualSourceUrls[datasource] && manualSourceUrls[datasource][depName]) {
dep.sourceUrl = manualSourceUrls[datasource][depName]; dep.sourceUrl = manualSourceUrls[datasource][depName];
} }
if (dep.sourceUrl && dep.sourceUrl.includes('github.com')) {
dep.sourceUrl = parse(dep.sourceUrl);
}
if ( if (
!dep.sourceUrl && !dep.sourceUrl &&
dep.changelogUrl && dep.changelogUrl &&

View file

@ -62,4 +62,14 @@ describe('datasource/index', () => {
}); });
expect(res.sourceUrl).toEqual('https://abc.com'); expect(res.sourceUrl).toEqual('https://abc.com');
}); });
it('massages sourceUrl', async () => {
npmDatasource.getPkgReleases.mockReturnValue({
sourceUrl: 'scm:git@github.com:Jasig/cas.git',
});
const res = await datasource.getPkgReleases({
datasource: 'npm',
depName: 'cas',
});
expect(res.sourceUrl).toEqual('https://github.com/Jasig/cas');
});
}); });