fix(cake): fix explicit registryUrl (#26713)

This commit is contained in:
Nils Andresen 2024-01-18 18:37:53 +01:00 committed by GitHub
parent adc9884225
commit 1679f05b2a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 2 deletions

View file

@ -2,6 +2,8 @@ foo
#addin nuget:?package=Foo.Foo
#addin "nuget:?package=Bim.Bim&version=6.6.6"
#tool nuget:https://example.com?package=Bar.Bar&version=2.2.2
#tool nuget:https://example.com/feed/v3/?package=Cake.Git&version=2.2.3
#tool nuget:https://example.com/feed/v3/index.json?package=Cake.MinVer&version=2.2.4
#module nuget:file:///tmp/?package=Baz.Baz&version=3.3.3
#load nuget:?package=Cake.7zip&version=1.0.3
#l nuget:?package=Cake.asciidoctorj&version=1.0.0

View file

@ -7,7 +7,12 @@ describe('modules/manager/cake/index', () => {
deps: [
{ depName: 'Foo.Foo', currentValue: undefined },
{ depName: 'Bim.Bim', currentValue: '6.6.6' },
{ depName: 'Bar.Bar', registryUrls: ['https://example.com'] },
{ depName: 'Bar.Bar', registryUrls: ['https://example.com/'] },
{ depName: 'Cake.Git', registryUrls: ['https://example.com/feed/v3/'] },
{
depName: 'Cake.MinVer',
registryUrls: ['https://example.com/feed/v3/index.json'],
},
{ depName: 'Baz.Baz', skipReason: 'unsupported-url' },
{ depName: 'Cake.7zip', currentValue: '1.0.3' },
{ depName: 'Cake.asciidoctorj', currentValue: '1.0.0' },

View file

@ -31,7 +31,8 @@ function parseDependencyLine(line: string): PackageDependency | null {
const isEmptyHost = url.startsWith('?');
url = isEmptyHost ? `http://localhost/${url}` : url;
const { origin: registryUrl, protocol, searchParams } = new URL(url);
const { origin, pathname, protocol, searchParams } = new URL(url);
const registryUrl = `${origin}${pathname}`;
const depName = searchParams.get('package')!;
const currentValue = searchParams.get('version') ?? undefined;