| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,7 +33,7 @@ const { | |||
| 33 | 33 | ERR_WORKER_UNSERIALIZABLE_ERROR, | |
| 34 | 34 | } = require('internal/errors').codes; | |
| 35 | 35 | const { exitCodes: { kUnsettledTopLevelAwait } } = internalBinding('errors'); | |
| 36 | - const { URL } = require('internal/url'); | ||
| 36 | + const { URLParse } = require('internal/url'); | ||
| 37 | 37 | const { canParse: URLCanParse } = internalBinding('url'); | |
| 38 | 38 | const { receiveMessageOnPort } = require('worker_threads'); | |
| 39 | 39 | const { | |
@@ -403,11 +403,7 @@ class Hooks { | |||
| 403 | 403 | ||
| 404 | 404 | let responseURLObj; | |
| 405 | 405 | if (typeof responseURL === 'string') { | |
| 406 | - try { | ||
| 407 | - responseURLObj = new URL(responseURL); | ||
| 408 | - } catch { | ||
| 409 | - // responseURLObj not defined will throw in next branch. | ||
| 410 | - } | ||
| 406 | + responseURLObj = URLParse(responseURL); | ||
| 411 | 407 | } | |
| 412 | 408 | ||
| 413 | 409 | if (responseURLObj?.href !== responseURL) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,14 +29,13 @@ const { | |||
| 29 | 29 | ERR_UNKNOWN_MODULE_FORMAT, | |
| 30 | 30 | } = require('internal/errors').codes; | |
| 31 | 31 | const { getOptionValue } = require('internal/options'); | |
| 32 | - const { isURL, pathToFileURL, URL } = require('internal/url'); | ||
| 32 | + const { isURL, pathToFileURL, URLParse } = require('internal/url'); | ||
| 33 | 33 | const { emitExperimentalWarning, kEmptyObject } = require('internal/util'); | |
| 34 | 34 | const { | |
| 35 | 35 | compileSourceTextModule, | |
| 36 | 36 | getDefaultConditions, | |
| 37 | 37 | } = require('internal/modules/esm/utils'); | |
| 38 | 38 | const { kImplicitTypeAttribute } = require('internal/modules/esm/assert'); | |
| 39 | - const { canParse } = internalBinding('url'); | ||
| 40 | 39 | const { ModuleWrap, kEvaluating, kEvaluated } = internalBinding('module_wrap'); | |
| 41 | 40 | const { | |
| 42 | 41 | urlToFilename, | |
@@ -322,8 +321,9 @@ class ModuleLoader { | |||
| 322 | 321 | getModuleJobForRequire(specifier, parentURL, importAttributes) { | |
| 323 | 322 | assert(getOptionValue('--experimental-require-module')); | |
| 324 | 323 | ||
| 325 | - if (canParse(specifier)) { | ||
| 326 | - const protocol = new URL(specifier).protocol; | ||
| 324 | + const parsed = URLParse(specifier); | ||
| 325 | + if (parsed != null) { | ||
| 326 | + const protocol = parsed.protocol; | ||
| 327 | 327 | if (protocol === 'https:' || protocol === 'http:') { | |
| 328 | 328 | throw new ERR_NETWORK_IMPORT_DISALLOWED(specifier, parentURL, | |
| 329 | 329 | 'ES modules cannot be loaded by require() from the network'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,7 +39,7 @@ const kSourceMappingURLMagicComment = /\/[*/]#\s+sourceMappingURL=(?<sourceMappi | |||
| 39 | 39 | const kSourceURLMagicComment = /\/[*/]#\s+sourceURL=(?<sourceURL>[^\s]+)/g; | |
| 40 | 40 | ||
| 41 | 41 | const { isAbsolute } = require('path'); | |
| 42 | - const { fileURLToPath, pathToFileURL, URL } = require('internal/url'); | ||
| 42 | + const { fileURLToPath, pathToFileURL, URL, URLParse } = require('internal/url'); | ||
| 43 | 43 | ||
| 44 | 44 | let SourceMap; | |
| 45 | 45 | ||
@@ -209,21 +209,20 @@ function maybeCacheGeneratedSourceMap(content) { | |||
| 209 | 209 | * @returns {object} deserialized source map JSON object | |
| 210 | 210 | */ | |
| 211 | 211 | function dataFromUrl(sourceURL, sourceMappingURL) { | |
| 212 | - try { | ||
| 213 | - const url = new URL(sourceMappingURL); | ||
| 212 | + const url = URLParse(sourceMappingURL); | ||
| 213 | + | ||
| 214 | + if (url != null) { | ||
| 214 | 215 | switch (url.protocol) { | |
| 215 | 216 | case 'data:': | |
| 216 | 217 | return sourceMapFromDataUrl(sourceURL, url.pathname); | |
| 217 | 218 | default: | |
| 218 | 219 | debug(`unknown protocol ${url.protocol}`); | |
| 219 | 220 | return null; | |
| 220 | 221 | } | |
| 221 | - } catch (err) { | ||
| 222 | - debug(err); | ||
| 223 | - // If no scheme is present, we assume we are dealing with a file path. | ||
| 224 | - const mapURL = new URL(sourceMappingURL, sourceURL).href; | ||
| 225 | - return sourceMapFromFile(mapURL); | ||
| 226 | 222 | } | |
| 223 | + | ||
| 224 | + const mapURL = new URL(sourceMappingURL, sourceURL).href; | ||
| 225 | + return sourceMapFromFile(mapURL); | ||
| 227 | 226 | } | |
| 228 | 227 | ||
| 229 | 228 | // Cache the length of each line in the file that a source map was extracted | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1601,6 +1601,7 @@ module.exports = { | |||
| 1601 | 1601 | installObjectURLMethods, | |
| 1602 | 1602 | URL, | |
| 1603 | 1603 | URLSearchParams, | |
| 1604 | + URLParse: URL.parse, | ||
| 1604 | 1605 | domainToASCII, | |
| 1605 | 1606 | domainToUnicode, | |
| 1606 | 1607 | urlToHttpOptions, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments