| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -281,6 +281,10 @@ const buffer = readFileSync(new URL('./data.proto', import.meta.url)); | |||
| 281 | 281 | added: | |
| 282 | 282 | - v13.9.0 | |
| 283 | 283 | - v12.16.2 | |
| 284 | + changes: | ||
| 285 | + - version: REPLACEME | ||
| 286 | + pr-url: https://github.com/nodejs/node/pull/38587 | ||
| 287 | + description: Add support for WHATWG `URL` object to `parentURL` parameter. | ||
| 284 | 288 | --> | |
| 285 | 289 | ||
| 286 | 290 | > Stability: 1 - Experimental | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,15 +13,15 @@ const { | |||
| 13 | 13 | } = primordials; | |
| 14 | 14 | ||
| 15 | 15 | const { | |
| 16 | + ERR_INVALID_ARG_TYPE, | ||
| 16 | 17 | ERR_INVALID_ARG_VALUE, | |
| 17 | 18 | ERR_INVALID_MODULE_SPECIFIER, | |
| 18 | 19 | ERR_INVALID_RETURN_PROPERTY, | |
| 19 | 20 | ERR_INVALID_RETURN_PROPERTY_VALUE, | |
| 20 | 21 | ERR_INVALID_RETURN_VALUE, | |
| 21 | 22 | ERR_UNKNOWN_MODULE_FORMAT | |
| 22 | 23 | } = require('internal/errors').codes; | |
| 23 | - const { URL, pathToFileURL } = require('internal/url'); | ||
| 24 | - const { validateString } = require('internal/validators'); | ||
| 24 | + const { URL, pathToFileURL, isURLInstance } = require('internal/url'); | ||
| 25 | 25 | const ModuleMap = require('internal/modules/esm/module_map'); | |
| 26 | 26 | const ModuleJob = require('internal/modules/esm/module_job'); | |
| 27 | 27 | ||
@@ -83,8 +83,8 @@ class Loader { | |||
| 83 | 83 | ||
| 84 | 84 | async resolve(specifier, parentURL) { | |
| 85 | 85 | const isMain = parentURL === undefined; | |
| 86 | - if (!isMain) | ||
| 87 | - validateString(parentURL, 'parentURL'); | ||
| 86 | + if (!isMain && typeof parentURL !== 'string' && !isURLInstance(parentURL)) | ||
| 87 | + throw new ERR_INVALID_ARG_TYPE('parentURL', ['string', 'URL'], parentURL); | ||
| 88 | 88 | ||
| 89 | 89 | const resolveResponse = await this._resolve( | |
| 90 | 90 | specifier, { parentURL, conditions: DEFAULT_CONDITIONS }, defaultResolve); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,6 +19,19 @@ const fixtures = dirname.slice(0, dirname.lastIndexOf('/', dirname.length - 2) + | |||
| 19 | 19 | await import.meta.resolve('../fixtures/empty-with-bom.txt'), | |
| 20 | 20 | fixtures + 'empty-with-bom.txt'); | |
| 21 | 21 | assert.strictEqual(await import.meta.resolve('../fixtures/'), fixtures); | |
| 22 | + assert.strictEqual( | ||
| 23 | + await import.meta.resolve('../fixtures/', import.meta.url), | ||
| 24 | + fixtures); | ||
| 25 | + assert.strictEqual( | ||
| 26 | + await import.meta.resolve('../fixtures/', new URL(import.meta.url)), | ||
| 27 | + fixtures); | ||
| 28 | + await Promise.all( | ||
| 29 | + [[], {}, Symbol(), 0, 1, 1n, 1.1, () => {}, true, false].map((arg) => | ||
| 30 | + assert.rejects(import.meta.resolve('../fixtures/', arg), { | ||
| 31 | + code: 'ERR_INVALID_ARG_TYPE', | ||
| 32 | + }) | ||
| 33 | + ) | ||
| 34 | + ); | ||
| 22 | 35 | assert.strictEqual(await import.meta.resolve('baz/', fixtures), | |
| 23 | 36 | fixtures + 'node_modules/baz/'); | |
| 24 | 37 | })().then(mustCall()); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments