From 2f8a17160382efd92713cc5db3a99aab95196889 Mon Sep 17 00:00:00 2001 From: Svante Bengtson Date: Fri, 2 Aug 2024 22:07:49 +0200 Subject: [PATCH] Fix incorrect URL building (#1438) --- src/package-managers/npm.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/package-managers/npm.ts b/src/package-managers/npm.ts index 9f29f717..54e2c78a 100644 --- a/src/package-managers/npm.ts +++ b/src/package-managers/npm.ts @@ -59,9 +59,9 @@ const fetchPartialPackument = async ( accept: opts.fullMetadata ? fullDoc : corgiDoc, ...opts.headers, } - let url = path.join(registry, name) + const url = new URL(encodeURIComponent(name), registry) if (version) { - url = path.join(url, version) + url.pathname += `/${version}` } const fetchOptions = { ...opts, @@ -71,11 +71,11 @@ const fetchPartialPackument = async ( try { if (opts.fullMetadata) { - return npmRegistryFetch.json(url, fetchOptions) + return npmRegistryFetch.json(url.href, fetchOptions) } else { tag = tag || 'latest' // typescript does not type async iteratable stream correctly so we need to cast it - const stream = npmRegistryFetch.json.stream(url, '$*', fetchOptions) as unknown as IterableIterator<{ + const stream = npmRegistryFetch.json.stream(url.href, '$*', fetchOptions) as unknown as IterableIterator<{ key: keyof Packument value: Packument[keyof Packument] }>