Skip to content
Snippets Groups Projects
Unverified Commit d9b025bf authored by Sergei Zharinov's avatar Sergei Zharinov Committed by GitHub
Browse files

refactor(packagist): Remove deprecated URL API (#20547)

parent 68e4ad4e
No related branches found
No related tags found
No related merge requests found
import URL from 'url';
import { logger } from '../../../logger'; import { logger } from '../../../logger';
import { ExternalHostError } from '../../../types/errors/external-host-error'; import { ExternalHostError } from '../../../types/errors/external-host-error';
import { cache } from '../../../util/cache/package/decorator'; import { cache } from '../../../util/cache/package/decorator';
import * as hostRules from '../../../util/host-rules'; import * as hostRules from '../../../util/host-rules';
import type { HttpOptions } from '../../../util/http/types'; import type { HttpOptions } from '../../../util/http/types';
import * as p from '../../../util/promises'; 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 * as composerVersioning from '../../versioning/composer';
import { Datasource } from '../datasource'; import { Datasource } from '../datasource';
import type { GetReleasesConfig, ReleaseResult } from '../types'; import type { GetReleasesConfig, ReleaseResult } from '../types';
...@@ -42,7 +41,7 @@ export class PackagistDatasource extends Datasource { ...@@ -42,7 +41,7 @@ export class PackagistDatasource extends Datasource {
} }
private async getRegistryMeta(regUrl: string): Promise<RegistryMeta | null> { 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 opts = PackagistDatasource.getHostOpts(url);
const res = (await this.http.getJson<PackageMeta>(url, opts)).body; const res = (await this.http.getJson<PackageMeta>(url, opts)).body;
const meta: RegistryMeta = { const meta: RegistryMeta = {
...@@ -225,14 +224,14 @@ export class PackagistDatasource extends Datasource { ...@@ -225,14 +224,14 @@ export class PackagistDatasource extends Datasource {
} }
let pkgUrl: string; let pkgUrl: string;
if (packageName in providerPackages) { if (packageName in providerPackages) {
pkgUrl = URL.resolve( pkgUrl = resolveBaseUrl(
registryUrl, registryUrl,
providersUrl! providersUrl!
.replace('%package%', packageName) .replace('%package%', packageName)
.replace('%hash%', providerPackages[packageName]) .replace('%hash%', providerPackages[packageName])
); );
} else if (providersLazyUrl) { } else if (providersLazyUrl) {
pkgUrl = URL.resolve( pkgUrl = resolveBaseUrl(
registryUrl, registryUrl,
providersLazyUrl.replace('%package%', packageName) providersLazyUrl.replace('%package%', packageName)
); );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment