@@ -69,13 +69,39 @@ function normalizePackageDataNoErrors (pkg) {
6969 }
7070}
7171
72+ function quotemeta ( str ) {
73+ return str . replace ( / ( [ ^ A - Z a - z _ 0 - 9 / ] ) / g, '\\$1' )
74+ }
75+
76+ function tarballToVersion ( name , tb ) {
77+ const registry = quotemeta ( npm . config . get ( 'registry' ) )
78+ . replace ( / h t t p s ? : / , 'https?:' )
79+ . replace ( / ( [ ^ / ] ) $ / , '$1/' )
80+ let matchRegTarball
81+ if ( name ) {
82+ const nameMatch = quotemeta ( name )
83+ matchRegTarball = new RegExp ( `^${ registry } ${ nameMatch } /-/${ nameMatch } -(.*)[.]tgz$` )
84+ } else {
85+ matchRegTarball = new RegExp ( `^${ registry } (.*)?/-/\\1-(.*)[.]tgz$` )
86+ }
87+ const match = tb . match ( matchRegTarball )
88+ if ( ! match ) return
89+ return match [ 2 ] || match [ 1 ]
90+ }
91+
7292function inflatableChild ( onDiskChild , name , topPath , tree , sw , requested , opts ) {
7393 validate ( 'OSSOOOO|ZSSOOOO' , arguments )
7494 const usesIntegrity = (
7595 requested . registry ||
7696 requested . type === 'remote' ||
7797 requested . type === 'file'
7898 )
99+ const regTarball = tarballToVersion ( name , sw . version )
100+ if ( regTarball ) {
101+ sw . resolved = sw . version
102+ sw . version = regTarball
103+ }
104+ if ( sw . requires ) Object . keys ( sw . requires ) . map ( ( _ ) => { sw . requires [ _ ] = tarballToVersion ( _ , sw . requires [ _ ] ) || sw . requires [ _ ] } )
79105 const modernLink = requested . type === 'directory' && ! sw . from
80106 if ( hasModernMeta ( onDiskChild ) && childIsEquivalent ( sw , requested , onDiskChild ) ) {
81107 // The version on disk matches the shrinkwrap entry.
0 commit comments