Commit 885accd
authored
fix(arborist): only replace hostname for resolved URL (#8185)
Related to #6110
There is an edge case where if an npm project is using a registry with a
path the `replace-registry-host` is including the path from the registry
url.
Current Behavior:
- Inputs:
- `registry=https://internal.mycompany.com/artifactory/api/npm/npm-all`
- `replace-registry-host=always`
- resolved: "https://external.mycompany.com/artifactory/api/npm/npm-all"
(package-lock.json)
- Output:
"https://internal.mycompany.com/artifactory/api/npm/npm-all/api/npm/npm-all"
Expected Behavior:
- Inputs:
- `registry=https://internal.mycompany.com/artifactory/api/npm/npm-all`
- `replace-registry-host=always`
- resolved: "https://external.mycompany.com/artifactory/api/npm/npm-all"
(package-lock.json)
- Output: "https://internal.mycompany.com/artifactory/api/npm/npm-all"
This fix resolves this inconsistency by refactoring the logic to
construct URL objects from the registry and resolved strings and maps
the hostname of the new registry to the hostname of the resolved url
instead of doing string parsing.
I'm welcome to any feedback on this solution!1 parent 88a7b52 commit 885accd
2 files changed
+64
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
| |||
833 | 832 | | |
834 | 833 | | |
835 | 834 | | |
836 | | - | |
837 | | - | |
838 | | - | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
839 | 848 | | |
840 | 849 | | |
841 | | - | |
| 850 | + | |
842 | 851 | | |
843 | | - | |
844 | | - | |
845 | | - | |
846 | | - | |
847 | | - | |
848 | | - | |
849 | | - | |
850 | | - | |
851 | 852 | | |
852 | 853 | | |
853 | 854 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3171 | 3171 | | |
3172 | 3172 | | |
3173 | 3173 | | |
3174 | | - | |
| 3174 | + | |
3175 | 3175 | | |
3176 | 3176 | | |
3177 | 3177 | | |
| |||
3256 | 3256 | | |
3257 | 3257 | | |
3258 | 3258 | | |
3259 | | - | |
| 3259 | + | |
3260 | 3260 | | |
3261 | 3261 | | |
3262 | 3262 | | |
| |||
3296 | 3296 | | |
3297 | 3297 | | |
3298 | 3298 | | |
3299 | | - | |
| 3299 | + | |
3300 | 3300 | | |
3301 | 3301 | | |
3302 | 3302 | | |
| |||
3336 | 3336 | | |
3337 | 3337 | | |
3338 | 3338 | | |
3339 | | - | |
| 3339 | + | |
3340 | 3340 | | |
3341 | 3341 | | |
3342 | 3342 | | |
| |||
3375 | 3375 | | |
3376 | 3376 | | |
3377 | 3377 | | |
| 3378 | + | |
| 3379 | + | |
| 3380 | + | |
| 3381 | + | |
| 3382 | + | |
| 3383 | + | |
| 3384 | + | |
| 3385 | + | |
| 3386 | + | |
| 3387 | + | |
| 3388 | + | |
| 3389 | + | |
| 3390 | + | |
| 3391 | + | |
| 3392 | + | |
| 3393 | + | |
| 3394 | + | |
| 3395 | + | |
| 3396 | + | |
| 3397 | + | |
| 3398 | + | |
| 3399 | + | |
| 3400 | + | |
| 3401 | + | |
| 3402 | + | |
| 3403 | + | |
| 3404 | + | |
| 3405 | + | |
| 3406 | + | |
| 3407 | + | |
| 3408 | + | |
| 3409 | + | |
| 3410 | + | |
| 3411 | + | |
| 3412 | + | |
| 3413 | + | |
| 3414 | + | |
| 3415 | + | |
| 3416 | + | |
| 3417 | + | |
| 3418 | + | |
| 3419 | + | |
| 3420 | + | |
| 3421 | + | |
| 3422 | + | |
| 3423 | + | |
3378 | 3424 | | |
3379 | 3425 | | |
3380 | 3426 | | |
| |||
0 commit comments