From 5d040c27358a4eaf2dd1588c13ae4c5c7a1b872d Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Thu, 26 Oct 2017 21:52:00 +0200 Subject: [PATCH] module: fix #16476 extension lookups for top main --- lib/module.js | 2 +- test/parallel/test-module-main-extension-lookup.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 test/parallel/test-module-main-extension-lookup.js diff --git a/lib/module.js b/lib/module.js index d210c916252427..8216907ec53847 100644 --- a/lib/module.js +++ b/lib/module.js @@ -435,7 +435,7 @@ Module._load = function(request, parent, isMain) { ESMLoader.hook(hooks); } } - await ESMLoader.import(getURLFromFilePath(request).href); + await ESMLoader.import(getURLFromFilePath(request).pathname); })() .catch((e) => { console.error(e); diff --git a/test/parallel/test-module-main-extension-lookup.js b/test/parallel/test-module-main-extension-lookup.js new file mode 100644 index 00000000000000..0a8cc47c77b2ed --- /dev/null +++ b/test/parallel/test-module-main-extension-lookup.js @@ -0,0 +1,7 @@ +'use strict'; +require('../common'); +const { execFileSync } = require('child_process'); + +const node = process.argv[0]; + +execFileSync(node, ['--experimental-modules', 'test/es-module/test-esm-ok']);