|
@@ -56,14 +56,18 @@ Value RegExpConstructor::call()
|
|
|
Value RegExpConstructor::construct(Function&)
|
|
|
{
|
|
|
auto& vm = this->vm();
|
|
|
- if (!vm.argument_count())
|
|
|
- return RegExpObject::create(global_object(), "(?:)", "");
|
|
|
- auto pattern = vm.argument(0).to_string(global_object());
|
|
|
- if (vm.exception())
|
|
|
- return {};
|
|
|
- auto flags = vm.argument_count() > 1 ? vm.argument(1).to_string(global_object()) : "";
|
|
|
- if (vm.exception())
|
|
|
- return {};
|
|
|
+ String pattern = "";
|
|
|
+ String flags = "";
|
|
|
+ if (!vm.argument(0).is_undefined()) {
|
|
|
+ pattern = vm.argument(0).to_string(global_object());
|
|
|
+ if (vm.exception())
|
|
|
+ return {};
|
|
|
+ }
|
|
|
+ if (!vm.argument(1).is_undefined()) {
|
|
|
+ flags = vm.argument(1).to_string(global_object());
|
|
|
+ if (vm.exception())
|
|
|
+ return {};
|
|
|
+ }
|
|
|
return RegExpObject::create(global_object(), pattern, flags);
|
|
|
}
|
|
|
|