@@ -101,16 +101,16 @@ function emitTrailingSlashPatternDeprecation(match, pjsonUrl, base) {
101101
102102const doubleSlashRegEx = / [ / \\ ] [ / \\ ] / ;
103103
104- function emitInvalidSegmentDeprecation ( target , request , match , pjsonUrl , base ) {
104+ function emitInvalidSegmentDeprecation ( target , request , match , pjsonUrl , internal , base , isTarget ) {
105105 if ( ! pendingDeprecation ) { return ; }
106106 const pjsonPath = fileURLToPath ( pjsonUrl ) ;
107- const double = RegExpPrototypeExec ( doubleSlashRegEx , target ) !== null ;
107+ const double = RegExpPrototypeExec ( doubleSlashRegEx , isTarget ? target : request ) !== null ;
108108 process . emitWarning (
109109 `Use of deprecated ${ double ? 'double slash' :
110110 'leading or trailing slash matching' } resolving "${ target } " for module ` +
111111 `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 ) } ` : '' } .`,
114114 'DeprecationWarning' ,
115115 'DEP0166'
116116 ) ;
@@ -438,7 +438,7 @@ function resolvePackageTargetString(
438438 const resolvedTarget = pattern ?
439439 RegExpPrototypeSymbolReplace ( patternRegEx , target , ( ) => subpath ) :
440440 target ;
441- emitInvalidSegmentDeprecation ( resolvedTarget , request , match , packageJSONUrl , base ) ;
441+ emitInvalidSegmentDeprecation ( resolvedTarget , request , match , packageJSONUrl , internal , base , true ) ;
442442 }
443443 } else {
444444 throwInvalidPackageTarget ( match , target , packageJSONUrl , internal , base ) ;
@@ -461,7 +461,7 @@ function resolvePackageTargetString(
461461 const resolvedTarget = pattern ?
462462 RegExpPrototypeSymbolReplace ( patternRegEx , target , ( ) => subpath ) :
463463 target ;
464- emitInvalidSegmentDeprecation ( resolvedTarget , request , match , packageJSONUrl , base ) ;
464+ emitInvalidSegmentDeprecation ( resolvedTarget , request , match , packageJSONUrl , internal , base , false ) ;
465465 }
466466 } else {
467467 throwInvalidSubpath ( request , match , packageJSONUrl , internal , base ) ;
0 commit comments