From d9b025bf63427475bdfc69ed2d0f379638c68020 Mon Sep 17 00:00:00 2001 From: Sergei Zharinov <zharinov@users.noreply.github.com> Date: Tue, 21 Feb 2023 16:48:46 +0300 Subject: [PATCH] refactor(packagist): Remove deprecated URL API (#20547) --- lib/modules/datasource/packagist/index.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/modules/datasource/packagist/index.ts b/lib/modules/datasource/packagist/index.ts index f1d15e2dde..b2f9849e54 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) ); -- GitLab