mirror of
https://github.com/nodejs/node.git
synced 2024-11-24 03:07:54 +01:00
esm: fix import.meta.resolve crash
PR-URL: https://github.com/nodejs/node/pull/55777 Fixes: https://github.com/nodejs/node/issues/55518 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
parent
8531e072f3
commit
07e2819d5d
@ -412,7 +412,10 @@ void BindingData::GetPackageScopeConfig(
|
||||
}
|
||||
|
||||
auto file_url = url::FileURLToPath(realm->env(), *package_json_url);
|
||||
CHECK(file_url);
|
||||
if (!file_url) {
|
||||
url::ThrowInvalidURL(realm->env(), resolved.ToStringView(), std::nullopt);
|
||||
return;
|
||||
}
|
||||
error_context.specifier = resolved.ToString();
|
||||
auto package_json = GetPackageJSON(realm, *file_url, &error_context);
|
||||
if (package_json != nullptr) {
|
||||
|
@ -106,3 +106,15 @@ await assert.rejects(import('data:text/javascript,export default import.meta.res
|
||||
stdout: 'http://example.com/\n',
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
const result = await spawnPromisified(execPath, [
|
||||
'--no-warnings',
|
||||
'--experimental-import-meta-resolve',
|
||||
'--eval',
|
||||
'import.meta.resolve("foo", "http://example.com/bar.js")',
|
||||
]);
|
||||
assert.match(result.stderr, /ERR_INVALID_URL/);
|
||||
assert.strictEqual(result.stdout, '');
|
||||
assert.strictEqual(result.code, 1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user