From d73fed2e8d402ef510b78686a0585b1d12ac6e99 Mon Sep 17 00:00:00 2001 From: WATANABE Shinya Date: Tue, 12 Nov 2024 21:34:41 +0900 Subject: [PATCH] Fix for prefix overlapping in some cases --- llrt_core/src/module_loader/loader.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/llrt_core/src/module_loader/loader.rs b/llrt_core/src/module_loader/loader.rs index 574d5ccf14..33f40cfd32 100644 --- a/llrt_core/src/module_loader/loader.rs +++ b/llrt_core/src/module_loader/loader.rs @@ -138,13 +138,19 @@ impl CustomLoader { return (false, false, name, name); } + // If it starts with CJS_IMPORT_PREFIX, mark as from_cjs_import if let Some(cjs_path) = name.strip_prefix(CJS_IMPORT_PREFIX) { - // If it starts with CJS_IMPORT_PREFIX, mark as from_cjs_import + if let Some(cjs_path) = cjs_path.strip_prefix(CJS_LOADER_PREFIX) { + return (true, false, cjs_path, cjs_path); + } return (true, false, name, cjs_path); } + // If it starts with CJS_LOADER_PREFIX, mark as is_cjs if let Some(cjs_path) = name.strip_prefix(CJS_LOADER_PREFIX) { - // If it starts with CJS_LOADER_PREFIX, mark as is_cjs + if let Some(cjs_path) = cjs_path.strip_prefix(CJS_IMPORT_PREFIX) { + return (false, true, cjs_path, cjs_path); + } return (false, true, cjs_path, cjs_path); }