@@ -98,15 +98,15 @@ function emitTrailingSlashPatternDeprecation(match, pjsonUrl, base) {
98
98
99
99
const doubleSlashRegEx = / [ / \\ ] [ / \\ ] / ;
100
100
101
- function emitInvalidSegmentDeprecation ( target , request , match , pjsonUrl , base ) {
101
+ function emitInvalidSegmentDeprecation ( target , request , match , pjsonUrl , internal , base , isTarget ) {
102
102
const pjsonPath = fileURLToPath ( pjsonUrl ) ;
103
- const double = RegExpPrototypeExec ( doubleSlashRegEx , target ) !== null ;
103
+ const double = RegExpPrototypeExec ( doubleSlashRegEx , isTarget ? target : request ) !== null ;
104
104
process . emitWarning (
105
105
`Use of deprecated ${ double ? 'double slash' :
106
106
'leading or trailing slash matching' } resolving "${ target } " for module ` +
107
107
`request "${ request } " ${ request !== match ? `matched to "${ match } " ` : ''
108
- } in the "exports" field module resolution of the package at ${ pjsonPath } ${
109
- base ? ` imported from ${ fileURLToPath ( base ) } ` : '' } .`,
108
+ } in the "${ internal ? 'imports' : ' exports' } " field module resolution of the package at ${
109
+ pjsonPath } ${ base ? ` imported from ${ fileURLToPath ( base ) } ` : '' } .`,
110
110
'DeprecationWarning' ,
111
111
'DEP0166'
112
112
) ;
@@ -372,7 +372,7 @@ function resolvePackageTargetString(
372
372
const resolvedTarget = pattern ?
373
373
RegExpPrototypeSymbolReplace ( patternRegEx , target , ( ) => subpath ) :
374
374
target ;
375
- emitInvalidSegmentDeprecation ( resolvedTarget , request , match , packageJSONUrl , base ) ;
375
+ emitInvalidSegmentDeprecation ( resolvedTarget , request , match , packageJSONUrl , internal , base , true ) ;
376
376
}
377
377
} else {
378
378
throwInvalidPackageTarget ( match , target , packageJSONUrl , internal , base ) ;
@@ -395,7 +395,7 @@ function resolvePackageTargetString(
395
395
const resolvedTarget = pattern ?
396
396
RegExpPrototypeSymbolReplace ( patternRegEx , target , ( ) => subpath ) :
397
397
target ;
398
- emitInvalidSegmentDeprecation ( resolvedTarget , request , match , packageJSONUrl , base ) ;
398
+ emitInvalidSegmentDeprecation ( resolvedTarget , request , match , packageJSONUrl , internal , base , false ) ;
399
399
}
400
400
} else {
401
401
throwInvalidSubpath ( request , match , packageJSONUrl , internal , base ) ;
0 commit comments