diff --git a/lib/datasource/__snapshots__/metadata.spec.ts.snap b/lib/datasource/__snapshots__/metadata.spec.ts.snap index d114fca01e395d896143e9ce64bdbb424ca2d7b6..8c58352c4efc18cdda6c136475daf3ba10878d22 100644 --- a/lib/datasource/__snapshots__/metadata.spec.ts.snap +++ b/lib/datasource/__snapshots__/metadata.spec.ts.snap @@ -135,3 +135,27 @@ Object { "sourceUrl": "https://gitlab.com/meno/dropzone", } `; + +exports[`datasource/metadata Should massage github sourceUrls 1`] = ` +Object { + "releases": Array [ + Object { + "releaseTimestamp": "2018-07-13T10:14:17.000Z", + "version": "2.0.0", + }, + Object { + "releaseTimestamp": "2017-10-24T10:09:16.000Z", + "version": "2.0.0.dev1", + }, + Object { + "releaseTimestamp": "2019-01-20T19:59:28.000Z", + "version": "2.1.0", + }, + Object { + "releaseTimestamp": "2019-07-16T18:29:00.000Z", + "version": "2.2.0", + }, + ], + "sourceUrl": "https://github.com/some/repo", +} +`; diff --git a/lib/datasource/metadata.spec.ts b/lib/datasource/metadata.spec.ts index 71ff2932c4c2e41c38cce7c3634678e6ea17207a..81fceb357fe9514c64ac435c239d2903a89d3947 100644 --- a/lib/datasource/metadata.spec.ts +++ b/lib/datasource/metadata.spec.ts @@ -76,6 +76,28 @@ describe('datasource/metadata', () => { }); }); + it('Should massage github sourceUrls', () => { + const dep: ReleaseResult = { + sourceUrl: 'https://some.github.com/repo', + releases: [ + { version: '2.0.0', releaseTimestamp: '2018-07-13T10:14:17.000Z' }, + { + version: '2.0.0.dev1', + releaseTimestamp: '2017-10-24T10:09:16.000Z', + }, + { version: '2.1.0', releaseTimestamp: '2019-01-20T19:59:28.000Z' }, + { version: '2.2.0', releaseTimestamp: '2019-07-16T18:29:00.000Z' }, + ], + }; + const datasource = PypiDatasource.id; + const lookupName = 'django-filter'; + + addMetaData(dep, datasource, lookupName); + expect(dep).toMatchSnapshot({ + sourceUrl: 'https://github.com/some/repo', + }); + }); + it('Should handle parsing of sourceUrls correctly for GitLab also', () => { const dep: ReleaseResult = { sourceUrl: 'https://gitlab.com/meno/dropzone/tree/master', diff --git a/lib/datasource/metadata.ts b/lib/datasource/metadata.ts index 95b611da71d0c8b5f2271ec9031a4dbb52a87178..d9685047d49807982c7a2b0cc9a04c44b45f99bc 100644 --- a/lib/datasource/metadata.ts +++ b/lib/datasource/metadata.ts @@ -107,10 +107,16 @@ const manualSourceUrls = { }, }; +const githubPages = regEx('^https://([^.]+).github.com/([^/]+)$'); +const gitPrefix = regEx('^git:/?/?'); + function massageGithubUrl(url: string): string { return url .replace('http:', 'https:') - .replace(regEx(/^git:\/?\/?/), 'https://') + .replace('http+git:', 'https:') + .replace('https+git:', 'https:') + .replace(gitPrefix, 'https://') + .replace(githubPages, 'https://github.com/$1/$2') .replace('www.github.com', 'github.com') .split('/') .slice(0, 5)