Skip to content

Commit a2923a9

Browse files
committed
parentURL, responseURL -> parentUrl, responseUrl
1 parent 0cb156b commit a2923a9

17 files changed

+111
-111
lines changed

doc/api/esm.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ changes:
749749
* `context` {Object}
750750
* `conditions` {string\[]} Export conditions of the relevant `package.json`
751751
* `importAssertions` {Object}
752-
* `parentURL` {string|undefined} The module importing this one, or undefined
752+
* `parentUrl` {string|undefined} The module importing this one, or undefined
753753
if this is the Node.js entry point
754754
* `nextResolve` {Function} The subsequent `resolve` hook in the chain, or the
755755
Node.js default `resolve` hook after the last user-supplied `resolve` hook
@@ -790,15 +790,15 @@ Node.js module specifier resolution behavior_ when calling `defaultResolve`, the
790790
791791
```js
792792
export async function resolve(specifier, context, nextResolve) {
793-
const { parentURL = null } = context;
793+
const { parentUrl = null } = context;
794794

795795
if (Math.random() > 0.5) { // Some condition.
796796
// For some or all specifiers, do some custom logic for resolving.
797797
// Always return an object of the form {url: <string>}.
798798
return {
799799
shortCircuit: true,
800-
url: parentURL ?
801-
new URL(specifier, parentURL).href :
800+
url: parentUrl ?
801+
new URL(specifier, parentUrl).href :
802802
new URL(specifier).href,
803803
};
804804
}
@@ -1007,7 +1007,7 @@ and there is no security.
10071007
import { get } from 'node:https';
10081008
10091009
export function resolve(specifier, context, nextResolve) {
1010-
const { parentURL = null } = context;
1010+
const { parentUrl = null } = context;
10111011
10121012
// Normally Node.js would error on specifiers starting with 'https://', so
10131013
// this hook intercepts them and converts them into absolute URLs to be
@@ -1017,10 +1017,10 @@ export function resolve(specifier, context, nextResolve) {
10171017
shortCircuit: true,
10181018
url: specifier
10191019
};
1020-
} else if (parentURL && parentURL.startsWith('https://')) {
1020+
} else if (parentUrl && parentUrl.startsWith('https://')) {
10211021
return {
10221022
shortCircuit: true,
1023-
url: new URL(specifier, parentURL).href,
1023+
url: new URL(specifier, parentUrl).href,
10241024
};
10251025
}
10261026
@@ -1083,20 +1083,20 @@ import { cwd } from 'node:process';
10831083
import { fileURLToPath, pathToFileURL } from 'node:url';
10841084
import CoffeeScript from 'coffeescript';
10851085
1086-
const baseURL = pathToFileURL(`${cwd()}/`).href;
1086+
const baseUrl = pathToFileURL(`${cwd()}/`).href;
10871087
10881088
// CoffeeScript files end in .coffee, .litcoffee or .coffee.md.
10891089
const extensionsRegex = /\.coffee$|\.litcoffee$|\.coffee\.md$/;
10901090
10911091
export async function resolve(specifier, context, nextResolve) {
10921092
if (extensionsRegex.test(specifier)) {
1093-
const { parentURL = baseURL } = context;
1093+
const { parentUrl = baseUrl } = context;
10941094
10951095
// Node.js normally errors on unknown file extensions, so return a URL for
10961096
// specifiers ending in the CoffeeScript file extensions.
10971097
return {
10981098
shortCircuit: true,
1099-
url: new URL(specifier, parentURL).href
1099+
url: new URL(specifier, parentUrl).href
11001100
};
11011101
}
11021102

lib/internal/modules/esm/fetch_module.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ async function isLocalAddress(hostname) {
217217
* @param {ESModuleContext} context
218218
* @returns {ReturnType<typeof fetchWithRedirects>}
219219
*/
220-
function fetchModule(parsed, { parentURL }) {
220+
function fetchModule(parsed, { parentUrl }) {
221221
const { href } = parsed;
222222
const existing = cacheForGET.get(href);
223223
if (existing) {
@@ -228,7 +228,7 @@ function fetchModule(parsed, { parentURL }) {
228228
if (is !== true) {
229229
throw new ERR_NETWORK_IMPORT_DISALLOWED(
230230
href,
231-
parentURL,
231+
parentUrl,
232232
'http can only be used to load local resources (use https instead).'
233233
);
234234
}

lib/internal/modules/esm/get_format.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function getDataProtocolModuleFormat(parsed) {
4848

4949
/**
5050
* @param {URL} url
51-
* @param {{parentURL: string}} context
51+
* @param {{parentUrl: string}} context
5252
* @param {boolean} ignoreErrors
5353
* @returns {string}
5454
*/
@@ -85,7 +85,7 @@ function getFileProtocolModuleFormat(url, context, ignoreErrors) {
8585

8686
/**
8787
* @param {URL} url
88-
* @param {{parentURL: string}} context
88+
* @param {{parentUrl: string}} context
8989
* @returns {Promise<string> | undefined} only works when enabled
9090
*/
9191
function getHttpProtocolModuleFormat(url, context) {
@@ -101,7 +101,7 @@ function getHttpProtocolModuleFormat(url, context) {
101101

102102
/**
103103
* @param {URL | URL['href']} url
104-
* @param {{parentURL: string}} context
104+
* @param {{parentUrl: string}} context
105105
* @returns {Promise<string> | string | undefined} only works when enabled
106106
*/
107107
function defaultGetFormatWithoutErrors(url, context) {
@@ -113,7 +113,7 @@ function defaultGetFormatWithoutErrors(url, context) {
113113

114114
/**
115115
* @param {URL | URL['href']} url
116-
* @param {{parentURL: string}} context
116+
* @param {{parentUrl: string}} context
117117
* @returns {Promise<string> | string | undefined} only works when enabled
118118
*/
119119
function defaultGetFormat(url, context) {

lib/internal/modules/esm/load.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const DATA_URL_PATTERN = /^[^/]+\/[^,;]+(?:[^,]*?)(;base64)?,([\s\S]*)$/;
3131

3232
async function getSource(url, context) {
3333
const parsed = new URL(url);
34-
let responseURL = url;
34+
let responseUrl = url;
3535
let source;
3636
if (parsed.protocol === 'file:') {
3737
source = await readFileAsync(parsed);
@@ -48,7 +48,7 @@ async function getSource(url, context) {
4848
)) {
4949
const res = await fetchModule(parsed, context);
5050
source = await res.body;
51-
responseURL = res.resolvedHREF;
51+
responseUrl = res.resolvedHREF;
5252
} else {
5353
const supportedSchemes = ['file', 'data'];
5454
if (experimentalNetworkImports) {
@@ -59,7 +59,7 @@ async function getSource(url, context) {
5959
if (policy?.manifest) {
6060
policy.manifest.assertIntegrity(parsed, source);
6161
}
62-
return { responseURL, source };
62+
return { responseUrl, source };
6363
}
6464

6565

@@ -70,7 +70,7 @@ async function getSource(url, context) {
7070
* @returns {object}
7171
*/
7272
async function defaultLoad(url, context) {
73-
let responseURL = url;
73+
let responseUrl = url;
7474
const { importAssertions } = context;
7575
let {
7676
format,
@@ -89,12 +89,12 @@ async function defaultLoad(url, context) {
8989
) {
9090
source = null;
9191
} else if (source == null) {
92-
({ responseURL, source } = await getSource(url, context));
92+
({ responseUrl, source } = await getSource(url, context));
9393
}
9494

9595
return {
9696
format,
97-
responseURL,
97+
responseUrl,
9898
source,
9999
};
100100
}

lib/internal/modules/esm/loader.js

+33-33
Original file line numberDiff line numberDiff line change
@@ -321,14 +321,14 @@ class ESMLoader {
321321
* @param {string} specifier The string after `from` in an `import` statement,
322322
* or the first parameter of an `import()`
323323
* expression
324-
* @param {string | undefined} parentURL The URL of the module importing this
324+
* @param {string | undefined} parentUrl The URL of the module importing this
325325
* one, unless this is the Node.js entry
326326
* point.
327327
* @param {Record<string, string>} importAssertions Validations for the
328328
* module import.
329329
* @returns {Promise<ModuleJob>} The (possibly pending) module job
330330
*/
331-
async getModuleJob(specifier, parentURL, importAssertions) {
331+
async getModuleJob(specifier, parentUrl, importAssertions) {
332332
let importAssertionsForResolve;
333333

334334
// By default, `this.#loaders` contains just the Node default load hook
@@ -342,7 +342,7 @@ class ESMLoader {
342342
}
343343

344344
const { format, url } =
345-
await this.resolve(specifier, parentURL, importAssertionsForResolve);
345+
await this.resolve(specifier, parentUrl, importAssertionsForResolve);
346346

347347
let job = this.moduleMap.get(url, importAssertions.type);
348348

@@ -352,7 +352,7 @@ class ESMLoader {
352352
}
353353

354354
if (job === undefined) {
355-
job = this.#createModuleJob(url, importAssertions, parentURL, format);
355+
job = this.#createModuleJob(url, importAssertions, parentUrl, format);
356356
}
357357

358358
return job;
@@ -363,17 +363,17 @@ class ESMLoader {
363363
* @param {string} url The absolute URL that was resolved for this module
364364
* @param {Record<string, string>} importAssertions Validations for the
365365
* module import.
366-
* @param {string} [parentURL] The absolute URL of the module importing this
366+
* @param {string} [parentUrl] The absolute URL of the module importing this
367367
* one, unless this is the Node.js entry point
368368
* @param {string} [format] The format hint possibly returned by the
369369
* `resolve` hook
370370
* @returns {Promise<ModuleJob>} The (possibly pending) module job
371371
*/
372-
#createModuleJob(url, importAssertions, parentURL, format) {
372+
#createModuleJob(url, importAssertions, parentUrl, format) {
373373
const moduleProvider = async (url, isMain) => {
374374
const {
375375
format: finalFormat,
376-
responseURL,
376+
responseUrl,
377377
source,
378378
} = await this.load(url, {
379379
format,
@@ -383,14 +383,14 @@ class ESMLoader {
383383
const translator = translators.get(finalFormat);
384384

385385
if (!translator) {
386-
throw new ERR_UNKNOWN_MODULE_FORMAT(finalFormat, responseURL);
386+
throw new ERR_UNKNOWN_MODULE_FORMAT(finalFormat, responseUrl);
387387
}
388388

389-
return FunctionPrototypeCall(translator, this, responseURL, source, isMain);
389+
return FunctionPrototypeCall(translator, this, responseUrl, source, isMain);
390390
};
391391

392392
const inspectBrk = (
393-
parentURL === undefined &&
393+
parentUrl === undefined &&
394394
getOptionValue('--inspect-brk')
395395
);
396396

@@ -399,7 +399,7 @@ class ESMLoader {
399399
url,
400400
importAssertions,
401401
moduleProvider,
402-
parentURL === undefined,
402+
parentUrl === undefined,
403403
inspectBrk
404404
);
405405

@@ -416,14 +416,14 @@ class ESMLoader {
416416
* loader module.
417417
*
418418
* @param {string | string[]} specifiers Path(s) to the module.
419-
* @param {string} parentURL Path of the parent importing the module.
419+
* @param {string} parentUrl Path of the parent importing the module.
420420
* @param {Record<string, string>} importAssertions Validations for the
421421
* module import.
422422
* @returns {Promise<ExportedHooks | KeyedExports[]>}
423423
* A collection of module export(s) or a list of collections of module
424424
* export(s).
425425
*/
426-
async import(specifiers, parentURL, importAssertions) {
426+
async import(specifiers, parentUrl, importAssertions) {
427427
// For loaders, `import` is passed multiple things to process, it returns a
428428
// list pairing the url and exports collected. This is especially useful for
429429
// error messaging, to identity from where an export came. But, in most
@@ -439,7 +439,7 @@ class ESMLoader {
439439
const jobs = new Array(count);
440440

441441
for (let i = 0; i < count; i++) {
442-
jobs[i] = this.getModuleJob(specifiers[i], parentURL, importAssertions)
442+
jobs[i] = this.getModuleJob(specifiers[i], parentUrl, importAssertions)
443443
.then((job) => job.run())
444444
.then(({ module }) => module.getNamespace());
445445
}
@@ -550,27 +550,27 @@ class ESMLoader {
550550
format,
551551
source,
552552
} = loaded;
553-
let responseURL = loaded.responseURL;
553+
let responseUrl = loaded.responseUrl;
554554

555-
if (responseURL === undefined) {
556-
responseURL = url;
555+
if (responseUrl === undefined) {
556+
responseUrl = url;
557557
}
558558

559-
let responseURLObj;
560-
if (typeof responseURL === 'string') {
559+
let responseURL;
560+
if (typeof responseUrl === 'string') {
561561
try {
562-
responseURLObj = new URL(responseURL);
562+
responseURL = new URL(responseUrl);
563563
} catch {
564-
// responseURLObj not defined will throw in next branch.
564+
// responseURL not defined will throw in next branch.
565565
}
566566
}
567567

568-
if (responseURLObj?.href !== responseURL) {
568+
if (responseURL?.href !== responseUrl) {
569569
throw new ERR_INVALID_RETURN_PROPERTY_VALUE(
570570
'undefined or a fully resolved URL string',
571571
hookErrIdentifier,
572-
'responseURL',
573-
responseURL,
572+
'responseUrl',
573+
responseUrl,
574574
);
575575
}
576576

@@ -610,7 +610,7 @@ class ESMLoader {
610610

611611
return {
612612
format,
613-
responseURL,
613+
responseUrl,
614614
source,
615615
};
616616
}
@@ -713,27 +713,27 @@ class ESMLoader {
713713
*
714714
* @param {string} originalSpecifier The specified URL path of the module to
715715
* be resolved.
716-
* @param {string} [parentURL] The URL path of the module's parent.
716+
* @param {string} [parentUrl] The URL path of the module's parent.
717717
* @param {ImportAssertions} [importAssertions] Assertions from the import
718718
* statement or expression.
719719
* @returns {{ format: string, url: URL['href'] }}
720720
*/
721721
async resolve(
722722
originalSpecifier,
723-
parentURL,
723+
parentUrl,
724724
importAssertions = ObjectCreate(null)
725725
) {
726-
const isMain = parentURL === undefined;
726+
const isMain = parentUrl === undefined;
727727

728728
if (
729729
!isMain &&
730-
typeof parentURL !== 'string' &&
731-
!isURLInstance(parentURL)
730+
typeof parentUrl !== 'string' &&
731+
!isURLInstance(parentUrl)
732732
) {
733733
throw new ERR_INVALID_ARG_TYPE(
734-
'parentURL',
734+
'parentUrl',
735735
['string', 'URL'],
736-
parentURL,
736+
parentUrl,
737737
);
738738
}
739739
const resolvers = this.#resolvers;
@@ -749,7 +749,7 @@ class ESMLoader {
749749
const context = {
750750
conditions: DEFAULT_CONDITIONS,
751751
importAssertions,
752-
parentURL,
752+
parentUrl,
753753
};
754754

755755
const nextResolve = async (suppliedSpecifier, ctx = context) => {

0 commit comments

Comments
 (0)