@@ -14,7 +14,7 @@ const {
14
14
ERR_UNKNOWN_MODULE_FORMAT ,
15
15
} = require ( 'internal/errors' ) . codes ;
16
16
const { getOptionValue } = require ( 'internal/options' ) ;
17
- const { pathToFileURL } = require ( 'internal/url' ) ;
17
+ const { pathToFileURL, isURL } = require ( 'internal/url' ) ;
18
18
const { emitExperimentalWarning } = require ( 'internal/util' ) ;
19
19
const {
20
20
getDefaultConditions,
@@ -320,7 +320,7 @@ class ModuleLoader {
320
320
// eslint-disable-next-line no-use-before-define
321
321
this . setCustomizations ( new CustomizedModuleLoader ( ) ) ;
322
322
}
323
- return this . #customizations. register ( specifier , parentURL , data , transferList ) ;
323
+ return this . #customizations. register ( ` ${ specifier } ` , ` ${ parentURL } ` , data , transferList ) ;
324
324
}
325
325
326
326
/**
@@ -541,11 +541,11 @@ function getHooksProxy() {
541
541
542
542
/**
543
543
* Register a single loader programmatically.
544
- * @param {string } specifier
545
- * @param {string } [parentURL] Base to use when resolving `specifier`; optional if
544
+ * @param {string|import('url').URL } specifier
545
+ * @param {string|import('url').URL } [parentURL] Base to use when resolving `specifier`; optional if
546
546
* `specifier` is absolute. Same as `options.parentUrl`, just inline
547
547
* @param {object } [options] Additional options to apply, described below.
548
- * @param {string } [options.parentURL] Base to use when resolving `specifier`
548
+ * @param {string|import('url').URL } [options.parentURL] Base to use when resolving `specifier`
549
549
* @param {any } [options.data] Arbitrary data passed to the loader's `initialize` hook
550
550
* @param {any[] } [options.transferList] Objects in `data` that are changing ownership
551
551
* @returns {void } We want to reserve the return value for potential future extension of the API.
@@ -570,12 +570,12 @@ function getHooksProxy() {
570
570
*/
571
571
function register ( specifier , parentURL = undefined , options ) {
572
572
const moduleLoader = require ( 'internal/process/esm_loader' ) . esmLoader ;
573
- if ( parentURL != null && typeof parentURL === 'object' ) {
573
+ if ( parentURL != null && typeof parentURL === 'object' && ! isURL ( parentURL ) ) {
574
574
options = parentURL ;
575
575
parentURL = options . parentURL ;
576
576
}
577
577
moduleLoader . register (
578
- ` ${ specifier } ` ,
578
+ specifier ,
579
579
parentURL ?? 'data:' ,
580
580
options ?. data ,
581
581
options ?. transferList ,
0 commit comments