diff --git a/lib/datasource/metadata.js b/lib/datasource/metadata.js index 30cee026e0e16f9cf17c1016d4b50f26bde441af..52e40fabc9409f2a48b5f29b362490e13e5ebb0d 100644 --- a/lib/datasource/metadata.js +++ b/lib/datasource/metadata.js @@ -91,7 +91,9 @@ function addMetaData(dep, datasource, lookupName) { // Clean up any empty urls const urls = ['homepage', 'sourceUrl', 'changelogUrl']; for (const url of urls) { - if (!is.nonEmptyString(dep[url])) { + if (is.nonEmptyString(dep[url])) { + dep[url] = dep[url].trim(); + } else { delete dep[url]; } } diff --git a/test/datasource/index.spec.js b/test/datasource/index.spec.js index b752e9224a4d03f128e8373e3558c12a0c4cff31..ab10c10cbb77e055a4f713527593744847833d2c 100644 --- a/test/datasource/index.spec.js +++ b/test/datasource/index.spec.js @@ -52,4 +52,14 @@ describe('datasource/index', () => { expect(res).toMatchSnapshot(); expect(res.sourceUrl).toBeDefined(); }); + it('trims sourceUrl', async () => { + npmDatasource.getPkgReleases.mockReturnValue({ + sourceUrl: ' https://abc.com', + }); + const res = await datasource.getPkgReleases({ + datasource: 'npm', + depName: 'abc', + }); + expect(res.sourceUrl).toEqual('https://abc.com'); + }); });