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 <luigipinca@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Antoine du Hamel authored and Michaël Zasso committed 2024-10-04 10:20:19 +02:00
1 parent b6fc9adf5b
commit c56e324cb8
1 file changed
+1 -1
@@ -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);