@@ -949,22 +949,26 @@ function throwIfInvalidParentURL(parentURL) {
949949}
950950
951951function throwIfUnsupportedURLProtocol ( url ) {
952- if ( url . protocol !== 'file:' && url . protocol !== 'data:' &&
953- url . protocol !== 'node:' ) {
952+ // Avoid accessing the `protocol` property due to the lazy getters.
953+ const protocol = url . protocol ;
954+ if ( protocol !== 'file:' && protocol !== 'data:' &&
955+ protocol !== 'node:' ) {
954956 throw new ERR_UNSUPPORTED_ESM_URL_SCHEME ( url ) ;
955957 }
956958}
957959
958960function throwIfUnsupportedURLScheme ( parsed , experimentalNetworkImports ) {
961+ // Avoid accessing the `protocol` property due to the lazy getters.
962+ const protocol = parsed ?. protocol ;
959963 if (
960- parsed &&
961- parsed . protocol !== 'file:' &&
962- parsed . protocol !== 'data:' &&
964+ protocol &&
965+ protocol !== 'file:' &&
966+ protocol !== 'data:' &&
963967 (
964968 ! experimentalNetworkImports ||
965969 (
966- parsed . protocol !== 'https:' &&
967- parsed . protocol !== 'http:'
970+ protocol !== 'https:' &&
971+ protocol !== 'http:'
968972 )
969973 )
970974 ) {
@@ -1021,11 +1025,13 @@ function defaultResolve(specifier, context = {}) {
10211025 parsed = new URL ( specifier ) ;
10221026 }
10231027
1024- if ( parsed . protocol === 'data:' ||
1028+ // Avoid accessing the `protocol` property due to the lazy getters.
1029+ const protocol = parsed . protocol ;
1030+ if ( protocol === 'data:' ||
10251031 ( experimentalNetworkImports &&
10261032 (
1027- parsed . protocol === 'https:' ||
1028- parsed . protocol === 'http:'
1033+ protocol === 'https:' ||
1034+ protocol === 'http:'
10291035 )
10301036 )
10311037 ) {
0 commit comments