@@ -41,8 +41,10 @@ const shouldAbortOnUncaughtException =
41
41
getOptionValue ( '--abort-on-uncaught-exception' ) ;
42
42
const { abort, exit, _rawDebug } = process ;
43
43
44
+ const kTerminate = ( ) => null ;
45
+
44
46
// From https://url.spec.whatwg.org/#special-scheme
45
- const SPECIAL_SCHEMES = new SafeSet ( [
47
+ const kSpecialSchemes = new SafeSet ( [
46
48
'file:' ,
47
49
'ftp:' ,
48
50
'http:' ,
@@ -76,7 +78,7 @@ function REACTION_LOG(error) {
76
78
77
79
class Manifest {
78
80
/**
79
- * @type {Map<string, DependencyMapper> }
81
+ * @type {Map<string | null | undefined , DependencyMapper> }
80
82
*
81
83
* Used to compare a resource to the content body at the resource.
82
84
* `true` is used to signify that all integrities are allowed, otherwise,
@@ -139,6 +141,8 @@ class Manifest {
139
141
*/
140
142
constructor ( obj , manifestURL ) {
141
143
const scopes = this . #scopeDependencies;
144
+ scopes . set ( null , kTerminate ) ;
145
+ scopes . set ( undefined , kTerminate ) ;
142
146
const integrities = this . #resourceIntegrities;
143
147
const dependencies = this . #resourceDependencies;
144
148
let reaction = REACTION_THROW ;
@@ -205,18 +209,20 @@ class Manifest {
205
209
return ( toSpecifier , conditions ) => {
206
210
if ( toSpecifier in dependencyMap !== true ) {
207
211
if ( cascade === true ) {
208
- let scopeHREF ;
212
+ /** @type {string | null } */
213
+ let scopeHREF = resourceHREF ;
209
214
if ( typeof parentDeps === 'undefined' ) {
210
215
do {
211
- scopeHREF = this . #findScopeHREF( resourceHREF ) ;
216
+ scopeHREF = this . #findScopeHREF( scopeHREF ) ;
217
+ if ( scopeHREF === resourceHREF ) {
218
+ scopeHREF = null ;
219
+ }
220
+ if ( scopes . has ( scopeHREF ) ) {
221
+ break ;
222
+ }
212
223
} while (
213
- scopeHREF !== null &&
214
- scopes . has ( scopeHREF ) !== true
224
+ scopeHREF !== null
215
225
) ;
216
- }
217
- if ( scopeHREF === null ) {
218
- parentDeps = ( ) => null ;
219
- } else {
220
226
parentDeps = scopes . get ( scopeHREF ) ;
221
227
}
222
228
return parentDeps ( toSpecifier ) ;
@@ -417,7 +423,7 @@ class Manifest {
417
423
protocol = currentURL . protocol ;
418
424
}
419
425
// Only a few schemes are hierarchical
420
- if ( SPECIAL_SCHEMES . has ( currentURL . protocol ) ) {
426
+ if ( kSpecialSchemes . has ( currentURL . protocol ) ) {
421
427
// Make first '..' act like '.'
422
428
if ( ! StringPrototypeEndsWith ( currentURL . pathname , '/' ) ) {
423
429
currentURL . pathname += '/' ;
0 commit comments