| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 34221a1 commit 533afe8
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,7 +38,7 @@ const { | |||
| 38 | 38 | ERR_WORKER_UNSERIALIZABLE_ERROR, | |
| 39 | 39 | } = require('internal/errors').codes; | |
| 40 | 40 | const { exitCodes: { kUnfinishedTopLevelAwait } } = internalBinding('errors'); | |
| 41 | - const { URL } = require('internal/url'); | ||
| 41 | + const { URLParse } = require('internal/url'); | ||
| 42 | 42 | const { canParse: URLCanParse } = internalBinding('url'); | |
| 43 | 43 | const { receiveMessageOnPort } = require('worker_threads'); | |
| 44 | 44 | const { | |
@@ -471,11 +471,7 @@ class Hooks { | |||
| 471 | 471 | ||
| 472 | 472 | let responseURLObj; | |
| 473 | 473 | if (typeof responseURL === 'string') { | |
| 474 | - try { | ||
| 475 | - responseURLObj = new URL(responseURL); | ||
| 476 | - } catch { | ||
| 477 | - // responseURLObj not defined will throw in next branch. | ||
| 478 | - } | ||
| 474 | + responseURLObj = URLParse(responseURL); | ||
| 479 | 475 | } | |
| 480 | 476 | ||
| 481 | 477 | if (responseURLObj?.href !== responseURL) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,14 +28,13 @@ const { | |||
| 28 | 28 | ERR_UNKNOWN_MODULE_FORMAT, | |
| 29 | 29 | } = require('internal/errors').codes; | |
| 30 | 30 | const { getOptionValue } = require('internal/options'); | |
| 31 | - const { isURL, pathToFileURL, URL } = require('internal/url'); | ||
| 31 | + const { isURL, pathToFileURL, URLParse } = require('internal/url'); | ||
| 32 | 32 | const { emitExperimentalWarning, kEmptyObject } = require('internal/util'); | |
| 33 | 33 | const { | |
| 34 | 34 | compileSourceTextModule, | |
| 35 | 35 | getDefaultConditions, | |
| 36 | 36 | } = require('internal/modules/esm/utils'); | |
| 37 | 37 | const { kImplicitAssertType } = require('internal/modules/esm/assert'); | |
| 38 | - const { canParse } = internalBinding('url'); | ||
| 39 | 38 | const { ModuleWrap, kEvaluating, kEvaluated } = internalBinding('module_wrap'); | |
| 40 | 39 | const { | |
| 41 | 40 | urlToFilename, | |
@@ -321,8 +320,9 @@ class ModuleLoader { | |||
| 321 | 320 | getModuleJobForRequire(specifier, parentURL, importAttributes) { | |
| 322 | 321 | assert(getOptionValue('--experimental-require-module')); | |
| 323 | 322 | ||
| 324 | - if (canParse(specifier)) { | ||
| 325 | - const protocol = new URL(specifier).protocol; | ||
| 323 | + const parsed = URLParse(specifier); | ||
| 324 | + if (parsed != null) { | ||
| 325 | + const protocol = parsed.protocol; | ||
| 326 | 326 | if (protocol === 'https:' || protocol === 'http:') { | |
| 327 | 327 | throw new ERR_NETWORK_IMPORT_DISALLOWED(specifier, parentURL, | |
| 328 | 328 | '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 | |
|---|---|---|---|
@@ -1624,6 +1624,7 @@ module.exports = { | |||
| 1624 | 1624 | installObjectURLMethods, | |
| 1625 | 1625 | URL, | |
| 1626 | 1626 | URLSearchParams, | |
| 1627 | + URLParse: URL.parse, | ||
| 1627 | 1628 | domainToASCII, | |
| 1628 | 1629 | domainToUnicode, | |
| 1629 | 1630 | urlToHttpOptions, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments