Skip to content

Commit

Permalink
Fix incorrect URL building (#1438)
Browse files Browse the repository at this point in the history
  • Loading branch information
swantzter authored Aug 2, 2024
1 parent 2655e98 commit 2f8a171
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/package-managers/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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]
}>
Expand Down

0 comments on commit 2f8a171

Please sign in to comment.