Skip to content

[BUG] replace-registry-host doesn't support when two different registries have paths #6110

@pashakondratyev

Description

@pashakondratyev

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

I have a setup where there may be different registries for example
https://myRegistry.com/a/b/package/-/package-1.1.1.tgz
and
https://myRegistry2.com/a/b/package/-/package-1.1.1.tgz

the first registry would return for the tarball
https://myRegistry.com/a/b/package/-/package-1.1.1.tgz
and if we have replace-registry-host enabled it would replace it like this:
https://myRegistry2.com/a/b/a/b/package/-/package-1.1.1.tgz

This seems like a strange example, but the use case is myRegistry may be a public facing uri but we would want a way to hit the registries through another uri depending on how the environment is configured (for example if we can not hit the public uri from a protected environment)

Expected Behavior

I would expect replace-registry-host to be able to specify the path that should be replaced instead of just a registry, for example
--replaceRegistryHost=https://myRegistry2.com/a/b/

Steps To Reproduce

The registry can return a tarball that contains a different hostname than the registry
2.

registry=https://myRegistry1.com/a/b
replace-registry-host=always
  1. npm install
  2. Unable to hit the registry (certificate issues)

Environment

  • npm: 8.19.3
  • Node.js: 16.18.0
  • OS Name: MacOS
  • System Model Name: Macbook Pro
  • npm config:
; copy and paste output from `npm config ls` here

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next stepsRelease 8.xwork is associated with a specific npm 8 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions