From 96406610fa123dca5cc190e276563da8de52af69 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sun, 22 Sep 2024 12:01:41 +0200 Subject: [PATCH] test: fix `test-vm-context-dont-contextify` when path contains a space Because of the double encoding, the test would fail as soon as the path contains a space or any other char that's already encoded by `pathToFileURL`. PR-URL: https://github.com/nodejs/node/pull/55026 Reviewed-By: Luigi Pinca Reviewed-By: Richard Lau Reviewed-By: Chengzhong Wu Reviewed-By: James M Snell --- test/parallel/test-vm-context-dont-contextify.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-vm-context-dont-contextify.js b/test/parallel/test-vm-context-dont-contextify.js index 6cbd62e8947b3d..d75fc1438d364a 100644 --- a/test/parallel/test-vm-context-dont-contextify.js +++ b/test/parallel/test-vm-context-dont-contextify.js @@ -176,7 +176,7 @@ function checkFrozen(context) { const namespace = await import(moduleUrl.href); // Check dynamic import works const context = vm.createContext(vm.constants.DONT_CONTEXTIFY); - const script = new vm.Script(`import('${encodeURI(moduleUrl.href)}')`, { + const script = new vm.Script(`import(${JSON.stringify(moduleUrl)})`, { importModuleDynamically: vm.constants.USE_MAIN_CONTEXT_DEFAULT_LOADER, }); const promise = script.runInContext(context);