[gjs/ewlsh/cleanup-import-uris] modules: Remove double '//' from internal module URIs




commit 3550b8e78333b6811331cb6a6cf3066b38efd2d2
Author: Evan Welsh <contact evanwelsh com>
Date:   Sun Jan 30 10:28:04 2022 -0800

    modules: Remove double '//' from internal module URIs

 modules/internal/loader.js | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
---
diff --git a/modules/internal/loader.js b/modules/internal/loader.js
index 187933965..3e661496a 100644
--- a/modules/internal/loader.js
+++ b/modules/internal/loader.js
@@ -12,15 +12,18 @@ class ModuleLoader extends InternalModuleLoader {
         super(global, compileModule);
 
         /**
-         * @type {Set<string>}
+         * The set of "module" URI globs (the module search path)
+         *
+         * For example, having `"resource:///org/gnome/gjs/modules/esm/*.js"` in this
+         * set allows `import "system"` if
+         * `"resource:///org/gnome/gjs/modules/esm/system.js"` exists.
          *
-         * The set of "module" URIs (the module search path)
-         * For example, having "resource:///org/gnome/gjs/modules/esm/" in this
-         * set allows import "system" if
-         * "resource:///org/gnome/gjs/modules/esm/system.js" exists.
+         * Only `*` is supported as a replacement character, `**` is not supported.
+         *
+         * @type {Set<string>}
          */
         this.moduleURIs = new Set([
-            'resource:///org/gnome/gjs/modules/esm/',
+            'resource:///org/gnome/gjs/modules/esm/*.js',
         ]);
 
         /**
@@ -40,7 +43,7 @@ class ModuleLoader extends InternalModuleLoader {
         const builtURIs = [];
 
         for (const uri of moduleURIs) {
-            const builtURI = `${uri}/${specifier}.js`;
+            const builtURI = uri.replace('*', specifier);
             builtURIs.push(builtURI);
         }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]