@@ -101,16 +101,16 @@ function emitTrailingSlashPatternDeprecation(match, pjsonUrl, base) {
101
101
102
102
const doubleSlashRegEx = / [ / \\ ] [ / \\ ] / ;
103
103
104
- function emitInvalidSegmentDeprecation ( target , request , match , pjsonUrl , base ) {
104
+ function emitInvalidSegmentDeprecation ( target , request , match , pjsonUrl , internal , base , isTarget ) {
105
105
if ( ! pendingDeprecation ) { return ; }
106
106
const pjsonPath = fileURLToPath ( pjsonUrl ) ;
107
- const double = RegExpPrototypeExec ( doubleSlashRegEx , target ) !== null ;
107
+ const double = RegExpPrototypeExec ( doubleSlashRegEx , isTarget ? target : request ) !== null ;
108
108
process . emitWarning (
109
109
`Use of deprecated ${ double ? 'double slash' :
110
110
'leading or trailing slash matching' } resolving "${ target } " for module ` +
111
111
`request "${ request } " ${ request !== match ? `matched to "${ match } " ` : ''
112
- } in the "exports" field module resolution of the package at ${ pjsonPath } ${
113
- base ? ` imported from ${ fileURLToPath ( base ) } ` : '' } .`,
112
+ } in the "${ internal ? 'imports' : ' exports' } " field module resolution of the package at ${
113
+ pjsonPath } ${ base ? ` imported from ${ fileURLToPath ( base ) } ` : '' } .`,
114
114
'DeprecationWarning' ,
115
115
'DEP0166'
116
116
) ;
@@ -438,7 +438,7 @@ function resolvePackageTargetString(
438
438
const resolvedTarget = pattern ?
439
439
RegExpPrototypeSymbolReplace ( patternRegEx , target , ( ) => subpath ) :
440
440
target ;
441
- emitInvalidSegmentDeprecation ( resolvedTarget , request , match , packageJSONUrl , base ) ;
441
+ emitInvalidSegmentDeprecation ( resolvedTarget , request , match , packageJSONUrl , internal , base , true ) ;
442
442
}
443
443
} else {
444
444
throwInvalidPackageTarget ( match , target , packageJSONUrl , internal , base ) ;
@@ -461,7 +461,7 @@ function resolvePackageTargetString(
461
461
const resolvedTarget = pattern ?
462
462
RegExpPrototypeSymbolReplace ( patternRegEx , target , ( ) => subpath ) :
463
463
target ;
464
- emitInvalidSegmentDeprecation ( resolvedTarget , request , match , packageJSONUrl , base ) ;
464
+ emitInvalidSegmentDeprecation ( resolvedTarget , request , match , packageJSONUrl , internal , base , false ) ;
465
465
}
466
466
} else {
467
467
throwInvalidSubpath ( request , match , packageJSONUrl , internal , base ) ;
0 commit comments