Repository navigation
Commit b51d156
authored
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.
<!-- What / Why -->
<!-- Describe the request in detail. What it does and why it's being
changed. -->
## References
- Fixes #6110
1 parent 024e6d9 commit b51d156
4 files changed
Lines changed: 194 additions & 26 deletions
File tree
- tap-snapshots/test/lib
- workspaces
- arborist
- lib/arborist
- test/arborist
- config/lib/definitions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1813 | 1813 | | |
1814 | 1814 | | |
1815 | 1815 | | |
1816 | | - | |
| 1816 | + | |
| 1817 | + | |
| 1818 | + | |
| 1819 | + | |
| 1820 | + | |
| 1821 | + | |
| 1822 | + | |
| 1823 | + | |
1817 | 1824 | | |
1818 | 1825 | | |
1819 | 1826 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1014 | 1014 | | |
1015 | 1015 | | |
1016 | 1016 | | |
| 1017 | + | |
| 1018 | + | |
1017 | 1019 | | |
1018 | | - | |
1019 | | - | |
1020 | | - | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
1021 | 1026 | | |
1022 | | - | |
1023 | | - | |
1024 | | - | |
1025 | | - | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
1026 | 1031 | | |
1027 | | - | |
1028 | | - | |
| 1032 | + | |
| 1033 | + | |
1029 | 1034 | | |
1030 | | - | |
1031 | | - | |
1032 | | - | |
1033 | | - | |
1034 | | - | |
1035 | | - | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
1036 | 1038 | | |
1037 | | - | |
1038 | | - | |
1039 | | - | |
1040 | | - | |
1041 | | - | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
1042 | 1042 | | |
1043 | | - | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
1044 | 1049 | | |
1045 | | - | |
1046 | | - | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
1047 | 1053 | | |
1048 | 1054 | | |
1049 | 1055 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3792 | 3792 | | |
3793 | 3793 | | |
3794 | 3794 | | |
| 3795 | + | |
| 3796 | + | |
| 3797 | + | |
| 3798 | + | |
| 3799 | + | |
| 3800 | + | |
| 3801 | + | |
| 3802 | + | |
| 3803 | + | |
| 3804 | + | |
| 3805 | + | |
| 3806 | + | |
| 3807 | + | |
| 3808 | + | |
| 3809 | + | |
| 3810 | + | |
| 3811 | + | |
| 3812 | + | |
| 3813 | + | |
| 3814 | + | |
| 3815 | + | |
| 3816 | + | |
| 3817 | + | |
| 3818 | + | |
| 3819 | + | |
| 3820 | + | |
| 3821 | + | |
| 3822 | + | |
| 3823 | + | |
| 3824 | + | |
| 3825 | + | |
| 3826 | + | |
| 3827 | + | |
| 3828 | + | |
| 3829 | + | |
| 3830 | + | |
| 3831 | + | |
| 3832 | + | |
| 3833 | + | |
| 3834 | + | |
| 3835 | + | |
| 3836 | + | |
| 3837 | + | |
| 3838 | + | |
| 3839 | + | |
| 3840 | + | |
| 3841 | + | |
| 3842 | + | |
| 3843 | + | |
| 3844 | + | |
| 3845 | + | |
| 3846 | + | |
| 3847 | + | |
| 3848 | + | |
| 3849 | + | |
| 3850 | + | |
| 3851 | + | |
| 3852 | + | |
| 3853 | + | |
| 3854 | + | |
| 3855 | + | |
| 3856 | + | |
| 3857 | + | |
| 3858 | + | |
| 3859 | + | |
| 3860 | + | |
| 3861 | + | |
| 3862 | + | |
| 3863 | + | |
| 3864 | + | |
| 3865 | + | |
| 3866 | + | |
| 3867 | + | |
| 3868 | + | |
| 3869 | + | |
| 3870 | + | |
| 3871 | + | |
| 3872 | + | |
| 3873 | + | |
| 3874 | + | |
| 3875 | + | |
| 3876 | + | |
| 3877 | + | |
| 3878 | + | |
| 3879 | + | |
| 3880 | + | |
| 3881 | + | |
| 3882 | + | |
| 3883 | + | |
| 3884 | + | |
| 3885 | + | |
| 3886 | + | |
| 3887 | + | |
| 3888 | + | |
| 3889 | + | |
| 3890 | + | |
| 3891 | + | |
| 3892 | + | |
| 3893 | + | |
| 3894 | + | |
| 3895 | + | |
| 3896 | + | |
| 3897 | + | |
| 3898 | + | |
| 3899 | + | |
| 3900 | + | |
| 3901 | + | |
| 3902 | + | |
| 3903 | + | |
| 3904 | + | |
| 3905 | + | |
| 3906 | + | |
| 3907 | + | |
| 3908 | + | |
| 3909 | + | |
| 3910 | + | |
| 3911 | + | |
| 3912 | + | |
| 3913 | + | |
| 3914 | + | |
| 3915 | + | |
| 3916 | + | |
| 3917 | + | |
| 3918 | + | |
| 3919 | + | |
| 3920 | + | |
| 3921 | + | |
| 3922 | + | |
| 3923 | + | |
| 3924 | + | |
| 3925 | + | |
| 3926 | + | |
| 3927 | + | |
| 3928 | + | |
| 3929 | + | |
| 3930 | + | |
| 3931 | + | |
| 3932 | + | |
| 3933 | + | |
| 3934 | + | |
| 3935 | + | |
| 3936 | + | |
| 3937 | + | |
| 3938 | + | |
| 3939 | + | |
| 3940 | + | |
| 3941 | + | |
| 3942 | + | |
3795 | 3943 | | |
3796 | 3944 | | |
3797 | 3945 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2056 | 2056 | | |
2057 | 2057 | | |
2058 | 2058 | | |
2059 | | - | |
| 2059 | + | |
2060 | 2060 | | |
2061 | 2061 | | |
2062 | 2062 | | |
| |||
2067 | 2067 | | |
2068 | 2068 | | |
2069 | 2069 | | |
2070 | | - | |
| 2070 | + | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
2071 | 2078 | | |
2072 | 2079 | | |
2073 | 2080 | | |
| |||
0 commit comments