aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js
diff options
context:
space:
mode:
authorGravatar dave caruso <me@paperdave.net> 2023-03-12 06:43:32 -0400
committerGravatar GitHub <noreply@github.com> 2023-03-12 03:43:32 -0700
commit21f9fc828f9b115f2d0db5da025394e4aee9530e (patch)
treec16c95a255837703fc80ed1a916d16b01cf4c5dc /src/bun.js
parent8c91278a00edf6774148c7b41871d1f999cdb0e1 (diff)
downloadbun-21f9fc828f9b115f2d0db5da025394e4aee9530e.tar.gz
bun-21f9fc828f9b115f2d0db5da025394e4aee9530e.tar.zst
bun-21f9fc828f9b115f2d0db5da025394e4aee9530e.zip
fix `require.resolve` with an empty options object #2370 (#2371)
* fix #2370 and import-meta test * edit test to not allow transpiler optimization
Diffstat (limited to 'src/bun.js')
-rw-r--r--src/bun.js/bindings/ImportMetaObject.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/bun.js/bindings/ImportMetaObject.cpp b/src/bun.js/bindings/ImportMetaObject.cpp
index 89d59b541..f8b6d0f9b 100644
--- a/src/bun.js/bindings/ImportMetaObject.cpp
+++ b/src/bun.js/bindings/ImportMetaObject.cpp
@@ -84,9 +84,11 @@ static EncodedJSValue functionRequireResolve(JSC::JSGlobalObject* globalObject,
// require.resolve also supports a paths array
// we only support a single path
if (!fromValue.isUndefinedOrNull() && fromValue.isObject()) {
- if (JSC::JSArray* array = JSC::jsDynamicCast<JSC::JSArray*>(fromValue.getObject()->getIfPropertyExists(globalObject, JSC::Identifier::fromString(vm, "paths"_s)))) {
- if (array->length() > 0) {
- fromValue = array->getIndex(globalObject, 0);
+ if (JSValue pathsValue = fromValue.getObject()->getIfPropertyExists(globalObject, JSC::Identifier::fromString(vm, "paths"_s))) {
+ if (JSC::JSArray* array = JSC::jsDynamicCast<JSC::JSArray*>(pathsValue)) {
+ if (array->length() > 0) {
+ fromValue = array->getIndex(globalObject, 0);
+ }
}
}
}