@@ -41,8 +41,10 @@ const shouldAbortOnUncaughtException =
4141getOptionValue ( '--abort-on-uncaught-exception' ) ;
4242const { abort, exit, _rawDebug } = process ;
4343
44+ const kTerminate = ( ) => null ;
45+
4446// From https://url.spec.whatwg.org/#special-scheme
45- const SPECIAL_SCHEMES = new SafeSet ( [
47+ const kSpecialSchemes = new SafeSet ( [
4648'file:' ,
4749'ftp:' ,
4850'http:' ,
@@ -76,7 +78,7 @@ function REACTION_LOG(error) {
7678
7779class Manifest {
7880/**
79- * @type {Map<string, DependencyMapper> }
81+ * @type {Map<string | null | undefined , DependencyMapper> }
8082 *
8183 * Used to compare a resource to the content body at the resource.
8284 * `true` is used to signify that all integrities are allowed, otherwise,
@@ -139,6 +141,8 @@ class Manifest {
139141 */
140142constructor ( obj , manifestURL ) {
141143const scopes = this . #scopeDependencies;
144+ scopes . set ( null , kTerminate ) ;
145+ scopes . set ( undefined , kTerminate ) ;
142146const integrities = this . #resourceIntegrities;
143147const dependencies = this . #resourceDependencies;
144148let reaction = REACTION_THROW ;
@@ -205,18 +209,20 @@ class Manifest {
205209return ( toSpecifier , conditions ) => {
206210if ( toSpecifier in dependencyMap !== true ) {
207211if ( cascade === true ) {
208- let scopeHREF ;
212+ /** @type {string | null } */
213+ let scopeHREF = resourceHREF ;
209214if ( typeof parentDeps === 'undefined' ) {
210215do {
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+ }
212223} while (
213- scopeHREF !== null &&
214- scopes . has ( scopeHREF ) !== true
224+ scopeHREF !== null
215225) ;
216- }
217- if ( scopeHREF === null ) {
218- parentDeps = ( ) => null ;
219- } else {
220226parentDeps = scopes . get ( scopeHREF ) ;
221227}
222228return parentDeps ( toSpecifier ) ;
@@ -416,7 +422,7 @@ class Manifest {
416422protocol = currentURL . protocol ;
417423}
418424// Only a few schemes are hierarchical
419- if ( SPECIAL_SCHEMES . has ( currentURL . protocol ) ) {
425+ if ( kSpecialSchemes . has ( currentURL . protocol ) ) {
420426// Make first '..' act like '.'
421427if ( currentURL . pathname . slice ( - 1 ) !== '/' ) {
422428currentURL . pathname += '/' ;
0 commit comments