diff --git a/lib/modules/datasource/packagist/index.ts b/lib/modules/datasource/packagist/index.ts index f1d15e2ddee08fd1a01e7622e5caf0721cf3cd11..b2f9849e540aceca205ccff0e7209dfccc583948 100644 --- a/lib/modules/datasource/packagist/index.ts +++ b/lib/modules/datasource/packagist/index.ts @@ -1,11 +1,10 @@ -import URL from 'url'; import { logger } from '../../../logger'; import { ExternalHostError } from '../../../types/errors/external-host-error'; import { cache } from '../../../util/cache/package/decorator'; import * as hostRules from '../../../util/host-rules'; import type { HttpOptions } from '../../../util/http/types'; import * as p from '../../../util/promises'; -import { ensureTrailingSlash, joinUrlParts } from '../../../util/url'; +import { joinUrlParts, resolveBaseUrl } from '../../../util/url'; import * as composerVersioning from '../../versioning/composer'; import { Datasource } from '../datasource'; import type { GetReleasesConfig, ReleaseResult } from '../types'; @@ -42,7 +41,7 @@ export class PackagistDatasource extends Datasource { } private async getRegistryMeta(regUrl: string): Promise<RegistryMeta | null> { - const url = URL.resolve(ensureTrailingSlash(regUrl), 'packages.json'); + const url = resolveBaseUrl(regUrl, 'packages.json'); const opts = PackagistDatasource.getHostOpts(url); const res = (await this.http.getJson<PackageMeta>(url, opts)).body; const meta: RegistryMeta = { @@ -225,14 +224,14 @@ export class PackagistDatasource extends Datasource { } let pkgUrl: string; if (packageName in providerPackages) { - pkgUrl = URL.resolve( + pkgUrl = resolveBaseUrl( registryUrl, providersUrl! .replace('%package%', packageName) .replace('%hash%', providerPackages[packageName]) ); } else if (providersLazyUrl) { - pkgUrl = URL.resolve( + pkgUrl = resolveBaseUrl( registryUrl, providersLazyUrl.replace('%package%', packageName) );