| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 889add6 commit 269482f
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -894,16 +894,20 @@ function resolveAsCommonJS(specifier, parentURL) { | |||
| 894 | 894 | // TODO(@JakobJingleheimer): de-dupe `specifier` & `parsed` | |
| 895 | 895 | function checkIfDisallowedImport(specifier, parsed, parsedParentURL) { | |
| 896 | 896 | if (parsedParentURL) { | |
| 897 | + // Avoid accessing the `protocol` property due to the lazy getters. | ||
| 898 | + const parentProtocol = parsedParentURL.protocol; | ||
| 897 | 899 | if ( | |
| 898 | - parsedParentURL.protocol === 'http:' || | ||
| 899 | - parsedParentURL.protocol === 'https:' | ||
| 900 | + parentProtocol === 'http:' || | ||
| 901 | + parentProtocol === 'https:' | ||
| 900 | 902 | ) { | |
| 901 | 903 | if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) { | |
| 904 | + // Avoid accessing the `protocol` property due to the lazy getters. | ||
| 905 | + const parsedProtocol = parsed?.protocol; | ||
| 902 | 906 | // data: and blob: disallowed due to allowing file: access via | |
| 903 | 907 | // indirection | |
| 904 | - if (parsed && | ||
| 905 | - parsed.protocol !== 'https:' && | ||
| 906 | - parsed.protocol !== 'http:' | ||
| 908 | + if (parsedProtocol && | ||
| 909 | + parsedProtocol !== 'https:' && | ||
| 910 | + parsedProtocol !== 'http:' | ||
| 907 | 911 | ) { | |
| 908 | 912 | throw new ERR_NETWORK_IMPORT_DISALLOWED( | |
| 909 | 913 | specifier, | |
@@ -944,22 +948,26 @@ function throwIfInvalidParentURL(parentURL) { | |||
| 944 | 948 | } | |
| 945 | 949 | ||
| 946 | 950 | function throwIfUnsupportedURLProtocol(url) { | |
| 947 | - if (url.protocol !== 'file:' && url.protocol !== 'data:' && | ||
| 948 | - url.protocol !== 'node:') { | ||
| 951 | + // Avoid accessing the `protocol` property due to the lazy getters. | ||
| 952 | + const protocol = url.protocol; | ||
| 953 | + if (protocol !== 'file:' && protocol !== 'data:' && | ||
| 954 | + protocol !== 'node:') { | ||
| 949 | 955 | throw new ERR_UNSUPPORTED_ESM_URL_SCHEME(url); | |
| 950 | 956 | } | |
| 951 | 957 | } | |
| 952 | 958 | ||
| 953 | 959 | function throwIfUnsupportedURLScheme(parsed, experimentalNetworkImports) { | |
| 960 | + // Avoid accessing the `protocol` property due to the lazy getters. | ||
| 961 | + const protocol = parsed?.protocol; | ||
| 954 | 962 | if ( | |
| 955 | - parsed && | ||
| 956 | - parsed.protocol !== 'file:' && | ||
| 957 | - parsed.protocol !== 'data:' && | ||
| 963 | + protocol && | ||
| 964 | + protocol !== 'file:' && | ||
| 965 | + protocol !== 'data:' && | ||
| 958 | 966 | ( | |
| 959 | 967 | !experimentalNetworkImports || | |
| 960 | 968 | ( | |
| 961 | - parsed.protocol !== 'https:' && | ||
| 962 | - parsed.protocol !== 'http:' | ||
| 969 | + protocol !== 'https:' && | ||
| 970 | + protocol !== 'http:' | ||
| 963 | 971 | ) | |
| 964 | 972 | ) | |
| 965 | 973 | ) { | |
@@ -1016,11 +1024,13 @@ function defaultResolve(specifier, context = {}) { | |||
| 1016 | 1024 | parsed = new URL(specifier); | |
| 1017 | 1025 | } | |
| 1018 | 1026 | ||
| 1019 | - if (parsed.protocol === 'data:' || | ||
| 1027 | + // Avoid accessing the `protocol` property due to the lazy getters. | ||
| 1028 | + const protocol = parsed.protocol; | ||
| 1029 | + if (protocol === 'data:' || | ||
| 1020 | 1030 | (experimentalNetworkImports && | |
| 1021 | 1031 | ( | |
| 1022 | - parsed.protocol === 'https:' || | ||
| 1023 | - parsed.protocol === 'http:' | ||
| 1032 | + protocol === 'https:' || | ||
| 1033 | + protocol === 'http:' | ||
| 1024 | 1034 | ) | |
| 1025 | 1035 | ) | |
| 1026 | 1036 | ) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments