diff --git a/lib/manager/gitlabci-include/extract.ts b/lib/manager/gitlabci-include/extract.ts index d625bcc58f11af10c083d34ec4ef1c80e03449c6..42cee41ae4bfec2f168d235c2affdad50e2628ee 100644 --- a/lib/manager/gitlabci-include/extract.ts +++ b/lib/manager/gitlabci-include/extract.ts @@ -37,7 +37,7 @@ export function extractPackageFile( const dep = extractDepFromInclude(includeObj); if (dep) { if (config.endpoint) { - dep.registryUrls = [config.endpoint.replace('/api/v4/', '')]; + dep.registryUrls = [config.endpoint.replace(/\/api\/v4\/?/, '')]; } deps.push(dep); } diff --git a/test/manager/gitlabci-include/__snapshots__/extract.spec.ts.snap b/test/manager/gitlabci-include/__snapshots__/extract.spec.ts.snap index 3ef5d791d7c266d1795fb21a93d7f0a67a6756f3..17b7d537df940a26060758275b2b203cf8b9a577 100644 --- a/test/manager/gitlabci-include/__snapshots__/extract.spec.ts.snap +++ b/test/manager/gitlabci-include/__snapshots__/extract.spec.ts.snap @@ -7,26 +7,17 @@ Array [ "datasource": "gitlab", "depName": "mikebryant/include-source-example", "depType": "repository", - "registryUrls": Array [ - "http://gitlab.test", - ], }, Object { "currentValue": "master", "datasource": "gitlab", "depName": "mikebryant/include-source-example2", "depType": "repository", - "registryUrls": Array [ - "http://gitlab.test", - ], }, Object { "datasource": "gitlab", "depName": "mikebryant/include-source-example3", "depType": "repository", - "registryUrls": Array [ - "http://gitlab.test", - ], "skipReason": "unknown-version", }, ] diff --git a/test/manager/gitlabci-include/extract.spec.ts b/test/manager/gitlabci-include/extract.spec.ts index 57458c8e5a43cbfc06604ac10306268f747ee104..c44d73000df0f0bb181227b9cd8057d415f07d8f 100644 --- a/test/manager/gitlabci-include/extract.spec.ts +++ b/test/manager/gitlabci-include/extract.spec.ts @@ -1,6 +1,5 @@ import fs from 'fs'; import { extractPackageFile } from '../../../lib/manager/gitlabci-include/extract'; -import { ExtractConfig } from '../../../lib/manager/common'; const yamlFile = fs.readFileSync( 'test/manager/gitlabci-include/_fixtures/gitlab-ci.yaml', @@ -9,21 +8,27 @@ const yamlFile = fs.readFileSync( describe('lib/manager/gitlabci-include/extract', () => { describe('extractPackageFile()', () => { - let config: ExtractConfig; - beforeEach(() => { - config = { - endpoint: 'http://gitlab.test/api/v4/', - }; - }); it('returns null for empty', () => { expect( - extractPackageFile('nothing here', '.gitlab-ci.yml', config) + extractPackageFile('nothing here', '.gitlab-ci.yml', {}) ).toBeNull(); }); it('extracts multiple include blocks', () => { - const res = extractPackageFile(yamlFile, '.gitlab-ci.yml', config); + const res = extractPackageFile(yamlFile, '.gitlab-ci.yml', {}); expect(res.deps).toMatchSnapshot(); expect(res.deps).toHaveLength(3); }); + it('normalizes configured endpoints', () => { + const endpoints = [ + 'http://gitlab.test/api/v4', + 'http://gitlab.test/api/v4/', + ]; + endpoints.forEach(endpoint => { + const res = extractPackageFile(yamlFile, '.gitlab-ci.yml', { + endpoint, + }); + expect(res.deps[0].registryUrls[0]).toEqual('http://gitlab.test'); + }); + }); }); });