@@ -14,7 +14,7 @@ const {
1414 ERR_UNKNOWN_MODULE_FORMAT ,
1515} = require ( 'internal/errors' ) . codes ;
1616const { getOptionValue } = require ( 'internal/options' ) ;
17- const { pathToFileURL } = require ( 'internal/url' ) ;
17+ const { pathToFileURL, isURL } = require ( 'internal/url' ) ;
1818const { emitExperimentalWarning } = require ( 'internal/util' ) ;
1919const {
2020 getDefaultConditions,
@@ -320,7 +320,7 @@ class ModuleLoader {
320320 // eslint-disable-next-line no-use-before-define
321321 this . setCustomizations ( new CustomizedModuleLoader ( ) ) ;
322322 }
323- return this . #customizations. register ( specifier , parentURL , data , transferList ) ;
323+ return this . #customizations. register ( ` ${ specifier } ` , ` ${ parentURL } ` , data , transferList ) ;
324324 }
325325
326326 /**
@@ -541,11 +541,11 @@ function getHooksProxy() {
541541
542542/**
543543 * 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
546546 * `specifier` is absolute. Same as `options.parentUrl`, just inline
547547 * @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`
549549 * @param {any } [options.data] Arbitrary data passed to the loader's `initialize` hook
550550 * @param {any[] } [options.transferList] Objects in `data` that are changing ownership
551551 * @returns {void } We want to reserve the return value for potential future extension of the API.
@@ -570,12 +570,12 @@ function getHooksProxy() {
570570 */
571571function register ( specifier , parentURL = undefined , options ) {
572572 const moduleLoader = require ( 'internal/process/esm_loader' ) . esmLoader ;
573- if ( parentURL != null && typeof parentURL === 'object' ) {
573+ if ( parentURL != null && typeof parentURL === 'object' && ! isURL ( parentURL ) ) {
574574 options = parentURL ;
575575 parentURL = options . parentURL ;
576576 }
577577 moduleLoader . register (
578- ` ${ specifier } ` ,
578+ specifier ,
579579 parentURL ?? 'data:' ,
580580 options ?. data ,
581581 options ?. transferList ,
0 commit comments