diff --git a/packages/plugin-npm/sources/NpmSemverFetcher.ts b/packages/plugin-npm/sources/NpmSemverFetcher.ts index 1d331a4c0223..c5b1890b802e 100644 --- a/packages/plugin-npm/sources/NpmSemverFetcher.ts +++ b/packages/plugin-npm/sources/NpmSemverFetcher.ts @@ -81,6 +81,10 @@ export class NpmSemverFetcher implements Fetcher { registry = registry.replace(/^https:\/\/registry\.npmjs\.org($|\/)/, `https://registry.yarnpkg.com$1`); url = url.replace(/^https:\/\/registry\.npmjs\.org($|\/)/, `https://registry.yarnpkg.com$1`); + // some registries store the tar ball in a path with duplicated scope, + // e.g. `https://my.registry.com/@my-scope/package-a/-/@my-scope/package-a-0.0.1.tgz` + url = url.replace(new RegExp(`^(.+)\\/@${locator.scope}\\/(.+)\\/@${locator.scope}\\/(.+)$`), `$1/@${locator.scope}/$2/$3`); + if (url === registry + path) return true; if (url === registry + path.replace(/%2f/g, `/`))