@@ -13,7 +13,7 @@ const {
1313 ERR_UNKNOWN_MODULE_FORMAT ,
1414} = require ( 'internal/errors' ) . codes ;
1515const { getOptionValue } = require ( 'internal/options' ) ;
16- const { pathToFileURL } = require ( 'internal/url' ) ;
16+ const { pathToFileURL, isURL } = require ( 'internal/url' ) ;
1717const { emitExperimentalWarning } = require ( 'internal/util' ) ;
1818const {
1919 getDefaultConditions,
@@ -329,7 +329,7 @@ class ModuleLoader {
329329 // eslint-disable-next-line no-use-before-define
330330 this . setCustomizations ( new CustomizedModuleLoader ( ) ) ;
331331 }
332- return this . #customizations. register ( specifier , parentURL , data , transferList ) ;
332+ return this . #customizations. register ( ` ${ specifier } ` , ` ${ parentURL } ` , data , transferList ) ;
333333 }
334334
335335 /**
@@ -529,11 +529,11 @@ function getHooksProxy() {
529529
530530/**
531531 * 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
534534 * `specifier` is absolute. Same as `options.parentUrl`, just inline
535535 * @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`
537537 * @param {any } [options.data] Arbitrary data passed to the loader's `initialize` hook
538538 * @param {any[] } [options.transferList] Objects in `data` that are changing ownership
539539 * @returns {void } We want to reserve the return value for potential future extension of the API.
@@ -558,12 +558,12 @@ function getHooksProxy() {
558558 */
559559function register ( specifier , parentURL = undefined , options ) {
560560 const moduleLoader = require ( 'internal/process/esm_loader' ) . esmLoader ;
561- if ( parentURL != null && typeof parentURL === 'object' ) {
561+ if ( parentURL != null && typeof parentURL === 'object' && ! isURL ( parentURL ) ) {
562562 options = parentURL ;
563563 parentURL = options . parentURL ;
564564 }
565565 moduleLoader . register (
566- ` ${ specifier } ` ,
566+ specifier ,
567567 parentURL ?? 'data:' ,
568568 options ?. data ,
569569 options ?. transferList ,
0 commit comments