@@ -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,
@@ -321,7 +321,7 @@ class ModuleLoader {
321321 // eslint-disable-next-line no-use-before-define
322322 this . setCustomizations ( new CustomizedModuleLoader ( ) ) ;
323323 }
324- return this . #customizations. register ( specifier , parentURL , data , transferList ) ;
324+ return this . #customizations. register ( ` ${ specifier } ` , ` ${ parentURL } ` , data , transferList ) ;
325325 }
326326
327327 /**
@@ -542,11 +542,11 @@ function getHooksProxy() {
542542
543543/**
544544 * Register a single loader programmatically.
545- * @param {string } specifier
546- * @param {string } [parentURL] Base to use when resolving `specifier`; optional if
545+ * @param {string|import('url').URL } specifier
546+ * @param {string|import('url').URL } [parentURL] Base to use when resolving `specifier`; optional if
547547 * `specifier` is absolute. Same as `options.parentUrl`, just inline
548548 * @param {object } [options] Additional options to apply, described below.
549- * @param {string } [options.parentURL] Base to use when resolving `specifier`
549+ * @param {string|import('url').URL } [options.parentURL] Base to use when resolving `specifier`
550550 * @param {any } [options.data] Arbitrary data passed to the loader's `initialize` hook
551551 * @param {any[] } [options.transferList] Objects in `data` that are changing ownership
552552 * @returns {void } We want to reserve the return value for potential future extension of the API.
@@ -571,12 +571,12 @@ function getHooksProxy() {
571571 */
572572function register ( specifier , parentURL = undefined , options ) {
573573 const moduleLoader = require ( 'internal/process/esm_loader' ) . esmLoader ;
574- if ( parentURL != null && typeof parentURL === 'object' ) {
574+ if ( parentURL != null && typeof parentURL === 'object' && ! isURL ( parentURL ) ) {
575575 options = parentURL ;
576576 parentURL = options . parentURL ;
577577 }
578578 moduleLoader . register (
579- ` ${ specifier } ` ,
579+ specifier ,
580580 parentURL ?? 'data:' ,
581581 options ?. data ,
582582 options ?. transferList ,
0 commit comments