@@ -13,7 +13,7 @@ const {
13
13
ERR_UNKNOWN_MODULE_FORMAT ,
14
14
} = require ( 'internal/errors' ) . codes ;
15
15
const { getOptionValue } = require ( 'internal/options' ) ;
16
- const { pathToFileURL } = require ( 'internal/url' ) ;
16
+ const { pathToFileURL, isURL } = require ( 'internal/url' ) ;
17
17
const { emitExperimentalWarning } = require ( 'internal/util' ) ;
18
18
const {
19
19
getDefaultConditions,
@@ -329,7 +329,7 @@ class ModuleLoader {
329
329
// eslint-disable-next-line no-use-before-define
330
330
this . setCustomizations ( new CustomizedModuleLoader ( ) ) ;
331
331
}
332
- return this . #customizations. register ( specifier , parentURL , data , transferList ) ;
332
+ return this . #customizations. register ( ` ${ specifier } ` , ` ${ parentURL } ` , data , transferList ) ;
333
333
}
334
334
335
335
/**
@@ -529,11 +529,11 @@ function getHooksProxy() {
529
529
530
530
/**
531
531
* Register a single loader programmatically.
532
- * @param {string } specifier
533
- * @param {string } [parentURL] Base to use when resolving `specifier`; optional if
532
+ * @param {string|import('url').URL } specifier
533
+ * @param {string|import('url').URL } [parentURL] Base to use when resolving `specifier`; optional if
534
534
* `specifier` is absolute. Same as `options.parentUrl`, just inline
535
535
* @param {object } [options] Additional options to apply, described below.
536
- * @param {string } [options.parentURL] Base to use when resolving `specifier`
536
+ * @param {string|import('url').URL } [options.parentURL] Base to use when resolving `specifier`
537
537
* @param {any } [options.data] Arbitrary data passed to the loader's `initialize` hook
538
538
* @param {any[] } [options.transferList] Objects in `data` that are changing ownership
539
539
* @returns {void } We want to reserve the return value for potential future extension of the API.
@@ -558,12 +558,12 @@ function getHooksProxy() {
558
558
*/
559
559
function register ( specifier , parentURL = undefined , options ) {
560
560
const moduleLoader = require ( 'internal/process/esm_loader' ) . esmLoader ;
561
- if ( parentURL != null && typeof parentURL === 'object' ) {
561
+ if ( parentURL != null && typeof parentURL === 'object' && ! isURL ( parentURL ) ) {
562
562
options = parentURL ;
563
563
parentURL = options . parentURL ;
564
564
}
565
565
moduleLoader . register (
566
- ` ${ specifier } ` ,
566
+ specifier ,
567
567
parentURL ?? 'data:' ,
568
568
options ?. data ,
569
569
options ?. transferList ,
0 commit comments