1
1
'use strict';
2
2
3
3
const {
4
-
ArrayPrototypePush,
5
4
RegExpPrototypeExec,
6
5
decodeURIComponent,
7
6
} = primordials;
@@ -12,8 +11,6 @@ const { validateAttributes, emitImportAssertionWarning } = require('internal/mod
12
11
const { getOptionValue } = require('internal/options');
13
12
const { readFileSync } = require('fs');
14
13
15
-
const experimentalNetworkImports =
16
-
getOptionValue('--experimental-network-imports');
17
14
const defaultType =
18
15
getOptionValue('--experimental-default-type');
19
16
@@ -39,7 +36,7 @@ const DATA_URL_PATTERN = /^[^/]+\/[^,;]+(?:[^,]*?)(;base64)?,([\s\S]*)$/;
39
36
*/
40
37
async function getSource(url, context) {
41
38
const { protocol, href } = url;
42
-
let responseURL = href;
39
+
const responseURL = href;
43
40
let source;
44
41
if (protocol === 'file:') {
45
42
const { readFile: readFileAsync } = require('internal/fs/promises').exports;
@@ -51,19 +48,8 @@ async function getSource(url, context) {
51
48
}
52
49
const { 1: base64, 2: body } = match;
53
50
source = BufferFrom(decodeURIComponent(body), base64 ? 'base64' : 'utf8');
54
-
} else if (experimentalNetworkImports && (
55
-
protocol === 'https:' ||
56
-
protocol === 'http:'
57
-
)) {
58
-
const { fetchModule } = require('internal/modules/esm/fetch_module');
59
-
const res = await fetchModule(url, context);
60
-
source = await res.body;
61
-
responseURL = res.resolvedHREF;
62
51
} else {
63
52
const supportedSchemes = ['file', 'data'];
64
-
if (experimentalNetworkImports) {
65
-
ArrayPrototypePush(supportedSchemes, 'http', 'https');
66
-
}
67
53
throw new ERR_UNSUPPORTED_ESM_URL_SCHEME(url, supportedSchemes);
68
54
}
69
55
return { __proto__: null, responseURL, source };
@@ -121,7 +107,7 @@ async function defaultLoad(url, context = kEmptyObject) {
121
107
122
108
const urlInstance = new URL(url);
123
109
124
-
throwIfUnsupportedURLScheme(urlInstance, experimentalNetworkImports);
110
+
throwIfUnsupportedURLScheme(urlInstance);
125
111
126
112
if (urlInstance.protocol === 'node:') {
127
113
source = null;
@@ -224,9 +210,8 @@ function defaultLoadSync(url, context = kEmptyObject) {
224
210
* throws an error if the protocol is not one of the protocols
225
211
* that can be loaded in the default loader
226
212
* @param {URL} parsed
227
-
* @param {boolean} experimentalNetworkImports
228
213
*/
229
-
function throwIfUnsupportedURLScheme(parsed, experimentalNetworkImports) {
214
+
function throwIfUnsupportedURLScheme(parsed) {
230
215
// Avoid accessing the `protocol` property due to the lazy getters.
231
216
const protocol = parsed?.protocol;
232
217
if (
@@ -235,17 +220,11 @@ function throwIfUnsupportedURLScheme(parsed, experimentalNetworkImports) {
235
220
protocol !== 'data:' &&
236
221
protocol !== 'node:' &&
237
222
(
238
-
!experimentalNetworkImports ||
239
-
(
240
-
protocol !== 'https:' &&
241
-
protocol !== 'http:'
242
-
)
223
+
protocol !== 'https:' &&
224
+
protocol !== 'http:'
243
225
)
244
226
) {
245
227
const schemes = ['file', 'data', 'node'];
246
-
if (experimentalNetworkImports) {
247
-
ArrayPrototypePush(schemes, 'https', 'http');
248
-
}
249
228
throw new ERR_UNSUPPORTED_ESM_URL_SCHEME(parsed, schemes);
250
229
}
251
230
}
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4