GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |
GeezerVison is showing github.com — feat(arborist): extend replace-registry-host with URL prefix matching (#6110) by u2mejc · Pull Request #9672 · npm/cli Conversation
Contributor
Resolves where registries with a path component (e.g. https://myregistry.example.com/npm/b) caused resolved URLs in the lockfile to have their path duplicated when reify rewrote them. Rewrote
Updated the Added three integration tests using
References
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions…pm#6110) Resolves where registries with a path component (e.g. https://myregistry.example.com/npm/b) caused resolved URLs in the lockfile to have their path duplicated when reify rewrote them. Rewrote `#registryResolved` to unify all match-and-rewrite logic into a single pass. A single `new URL()` parse of `replaceRegistryHost` now drives all three match modes: - **Keyword / bare hostname** (`never`, `always`, `npmjs`, `registry.npmjs.org`): behaviour unchanged. `new URL()` throws for keywords, leaving `matchURL` null and falling through to the existing host-comparison or keyword short-circuit. - **Host-only URL** (e.g. `https://old.example.com/`): trailing slash normalises to an empty `matchPath`; treated identically to a bare hostname — only the host is replaced, and the registry path is prepended if not already present. - **Full URL with path** (e.g. `https://old.example.com/npm/b`): when the resolved URL's host and path both match the prefix, the entire matched prefix is replaced with the configured registry's full URL (host + path). The remainder of the resolved path is appended without duplication. If the resolved URL's path does not start with the configured prefix, `#registryResolved` returns the URL unchanged. Updated the `hint` and `description` for `replace-registry-host` to document the new full-URL-with-path mode and the host-only-URL mode. Added three integration tests using `tnock` (mismatched URL → nock throws, making URL assertions implicit and precise): 1. Full URL prefix match: `replaceRegistryHost=https://old.example.com/npm/b`, registry `https://new.example.com/npm/a` — verifies the old `/npm/b` prefix is replaced with `/npm/a`, not doubled to `/npm/a/npm/b/…`. 2. Host-only URL: `replaceRegistryHost=https://old.example.com/` — verifies only the host is swapped and the resolved path is preserved. 3. Path mismatch: `replaceRegistryHost=https://old.example.com/npm/c` but tarball under `/npm/b` — verifies the URL is left unchanged when the path prefix does not match.
owlstronaut
approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Contributor
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
owlstronaut
pushed a commit
that referenced
this pull request
…#6110) (#9694) Backport of #9672 to `release/v11`. Co-authored-by: Justin Clark <[email protected]>
6 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reviewers1 more reviewerUh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabelsProjectsMilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. [BUG]replace-registry-host doesn't support when two different registries have paths
Uh oh!
There was an error while loading. Please reload this page. Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later. | |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |