diff options
author | Jan Krems <jan.krems@gmail.com> | 2019-07-24 07:25:24 +0300 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-07-31 23:33:46 +0300 |
commit | 61f3a5c60ad78506e9e0caae061a04ccab878ca1 (patch) | |
tree | 06ca06f666a4986f46d460295a3397f659275518 /src/module_wrap.cc | |
parent | 9d37013ef0e0f0f243da6057498a79fd43a2f784 (diff) |
module: unify package exports test for CJS and ESM
Refs: https://github.com/nodejs/modules/issues/358
PR-URL: https://github.com/nodejs/node/pull/28831
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'src/module_wrap.cc')
-rw-r--r-- | src/module_wrap.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/module_wrap.cc b/src/module_wrap.cc index 503ca8a858e..522e7c2a458 100644 --- a/src/module_wrap.cc +++ b/src/module_wrap.cc @@ -847,8 +847,11 @@ Maybe<URL> PackageExportsResolve(Environment* env, std::string target(*target_utf8, target_utf8.length()); if (target.back() == '/' && target.substr(0, 2) == "./") { std::string subpath = pkg_subpath.substr(best_match_str.length()); - URL target_url(target + subpath, pjson_url); - return FinalizeResolution(env, target_url, base); + URL url_prefix(target, pjson_url); + URL target_url(subpath, url_prefix); + if (target_url.path().find(url_prefix.path()) == 0) { + return FinalizeResolution(env, target_url, base); + } } } } |