File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -105,8 +105,15 @@ class FetcherBase {
105105 this [ _readPackageJson ] = readPackageJsonFast
106106 }
107107
108- // config values: npmjs (default), never
109- this . replaceRegistryHost = opts . replaceRegistryHost === 'never' ? 'never' : 'npmjs'
108+ // config values: npmjs (default), never, always
109+ // we don't want to mutate the original value
110+ if ( opts . replaceRegistryHost !== 'never'
111+ && opts . replaceRegistryHost !== 'always'
112+ ) {
113+ this . replaceRegistryHost = 'npmjs'
114+ } else {
115+ this . replaceRegistryHost = opts . replaceRegistryHost
116+ }
110117
111118 this . defaultTag = opts . defaultTag || 'latest'
112119 this . registry = removeTrailingSlashes ( opts . registry || 'https://registry.npmjs.org' )
Original file line number Diff line number Diff line change @@ -5,18 +5,21 @@ const pacoteVersion = require('../package.json').version
55const fetch = require ( 'npm-registry-fetch' )
66const Minipass = require ( 'minipass' )
77// The default registry URL is a string of great magic.
8- const magic = / ^ h t t p s ? : \/ \ /r e g i s t r y \ .n p m j s \ .o r g \/ /
8+ const magicHost = ' https:/ /registry.npmjs.org'
99
1010const _cacheFetches = Symbol . for ( 'pacote.Fetcher._cacheFetches' )
1111const _headers = Symbol ( '_headers' )
1212class RemoteFetcher extends Fetcher {
1313 constructor ( spec , opts ) {
1414 super ( spec , opts )
1515 this . resolved = this . spec . fetchSpec
16- if ( this . replaceRegistryHost === 'npmjs'
17- && magic . test ( this . resolved )
18- && ! magic . test ( this . registry + '/' ) ) {
19- this . resolved = this . resolved . replace ( magic , this . registry + '/' )
16+ const resolvedURL = new URL ( this . resolved )
17+ if (
18+ ( this . replaceRegistryHost === 'npmjs'
19+ && resolvedURL . origin === magicHost )
20+ || this . replaceRegistryHost === 'always'
21+ ) {
22+ this . resolved = new URL ( resolvedURL . pathname , this . registry ) . href
2023 }
2124
2225 // nam is a fermented pork sausage that is good to eat
Original file line number Diff line number Diff line change 11{
22 "name" : " pacote" ,
3- "version" : " 13.1.1 " ,
3+ "version" : " 13.2.0 " ,
44 "description" : " JavaScript package downloader" ,
55 "author" : " GitHub Inc." ,
66 "bin" : {
2626 },
2727 "devDependencies" : {
2828 "@npmcli/eslint-config" : " ^3.0.1" ,
29- "@npmcli/template-oss" : " 3.2 .2" ,
29+ "@npmcli/template-oss" : " 3.4 .2" ,
3030 "hosted-git-info" : " ^5.0.0" ,
3131 "mutate-fs" : " ^2.1.1" ,
3232 "nock" : " ^13.2.4" ,
7474 },
7575 "templateOSS" : {
7676 "//@npmcli/template-oss" : " This file is partially managed by @npmcli/template-oss. Edits may be overwritten." ,
77- "version" : " 3.2 .2" ,
77+ "version" : " 3.4 .2" ,
7878 "windowsCI" : false
7979 }
8080}
Original file line number Diff line number Diff line change 138138 "npm-user-validate" : " ^1.0.1" ,
139139 "npmlog" : " ^6.0.2" ,
140140 "opener" : " ^1.5.2" ,
141- "pacote" : " ^13.1.1 " ,
141+ "pacote" : " ^13.2.0 " ,
142142 "parse-conflict-json" : " ^2.0.2" ,
143143 "proc-log" : " ^2.0.1" ,
144144 "qrcode-terminal" : " ^0.12.0" ,
55635563 }
55645564 },
55655565 "node_modules/pacote" : {
5566- "version" : " 13.1.1 " ,
5567- "resolved" : " https://registry.npmjs.org/pacote/-/pacote-13.1.1 .tgz" ,
5568- "integrity" : " sha512-MTT3k1OhUo+IpvoHGp25OwsRU0L+kJQM236OCywxvY4OIJ/YfloNW2/Yc3HMASH10BkfZaGMVK/pxybB7fWcLw ==" ,
5566+ "version" : " 13.2.0 " ,
5567+ "resolved" : " https://registry.npmjs.org/pacote/-/pacote-13.2.0 .tgz" ,
5568+ "integrity" : " sha512-IT4/xHT8eLi4cJdKSGCuqooWp2YwRP5OgrQypbBlLG8Ubzw+h7s57QbrA2SegQcdGefD81ZvuI+aL0JlfFcPCA ==" ,
55695569 "inBundle" : true ,
55705570 "dependencies" : {
55715571 "@npmcli/git" : " ^3.0.0" ,
1389813898 }
1389913899 },
1390013900 "pacote" : {
13901- "version" : " 13.1.1 " ,
13902- "resolved" : " https://registry.npmjs.org/pacote/-/pacote-13.1.1 .tgz" ,
13903- "integrity" : " sha512-MTT3k1OhUo+IpvoHGp25OwsRU0L+kJQM236OCywxvY4OIJ/YfloNW2/Yc3HMASH10BkfZaGMVK/pxybB7fWcLw ==" ,
13901+ "version" : " 13.2.0 " ,
13902+ "resolved" : " https://registry.npmjs.org/pacote/-/pacote-13.2.0 .tgz" ,
13903+ "integrity" : " sha512-IT4/xHT8eLi4cJdKSGCuqooWp2YwRP5OgrQypbBlLG8Ubzw+h7s57QbrA2SegQcdGefD81ZvuI+aL0JlfFcPCA ==" ,
1390413904 "requires" : {
1390513905 "@npmcli/git" : " ^3.0.0" ,
1390613906 "@npmcli/installed-package-contents" : " ^1.0.7" ,
Original file line number Diff line number Diff line change 107107 "npm-user-validate" : " ^1.0.1" ,
108108 "npmlog" : " ^6.0.2" ,
109109 "opener" : " ^1.5.2" ,
110- "pacote" : " ^13.1.1 " ,
110+ "pacote" : " ^13.2.0 " ,
111111 "parse-conflict-json" : " ^2.0.2" ,
112112 "proc-log" : " ^2.0.1" ,
113113 "qrcode-terminal" : " ^0.12.0" ,
You can’t perform that action at this time.
0 commit comments