|
@@ -481,7 +481,6 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::exec)
|
|
|
|
|
|
JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::flags)
|
|
|
{
|
|
|
-
|
|
|
|
|
|
|
|
|
auto regexp_object = TRY(this_object(vm));
|
|
@@ -513,7 +512,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::flags)
|
|
|
#undef __JS_ENUMERATE
|
|
|
|
|
|
|
|
|
- return PrimitiveString::create(vm, builder.to_byte_string());
|
|
|
+ return PrimitiveString::create(vm, builder.to_string_without_validation());
|
|
|
}
|
|
|
|
|
|
|
|
@@ -530,7 +529,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_match)
|
|
|
|
|
|
|
|
|
auto flags_value = TRY(regexp_object->get(vm.names.flags));
|
|
|
- auto flags = TRY(flags_value.to_byte_string(vm));
|
|
|
+ auto flags = TRY(flags_value.to_string(vm));
|
|
|
|
|
|
|
|
|
if (!flags.contains('g')) {
|
|
@@ -573,7 +572,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_match)
|
|
|
|
|
|
|
|
|
auto match_value = TRY(result.get(0));
|
|
|
- auto match_str = TRY(match_value.to_byte_string(vm));
|
|
|
+ auto match_str = TRY(match_value.to_string(vm));
|
|
|
|
|
|
|
|
|
MUST(array->create_data_property_or_throw(n, PrimitiveString::create(vm, match_str)));
|
|
@@ -606,7 +605,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_match_all)
|
|
|
|
|
|
|
|
|
auto flags_value = TRY(regexp_object->get(vm.names.flags));
|
|
|
- auto flags = TRY(flags_value.to_byte_string(vm));
|
|
|
+ auto flags = TRY(flags_value.to_string(vm));
|
|
|
|
|
|
|
|
|
|
|
@@ -651,13 +650,13 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_replace)
|
|
|
|
|
|
if (!replace_value.is_function()) {
|
|
|
|
|
|
- auto replace_string = TRY(replace_value.to_byte_string(vm));
|
|
|
+ auto replace_string = TRY(replace_value.to_string(vm));
|
|
|
replace_value = PrimitiveString::create(vm, move(replace_string));
|
|
|
}
|
|
|
|
|
|
|
|
|
auto flags_value = TRY(regexp_object->get(vm.names.flags));
|
|
|
- auto flags = TRY(flags_value.to_byte_string(vm));
|
|
|
+ auto flags = TRY(flags_value.to_string(vm));
|
|
|
|
|
|
|
|
|
bool global = flags.contains('g');
|
|
@@ -694,7 +693,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_replace)
|
|
|
|
|
|
|
|
|
auto match_value = TRY(result.get(vm, 0));
|
|
|
- auto match_str = TRY(match_value.to_byte_string(vm));
|
|
|
+ auto match_str = TRY(match_value.to_string(vm));
|
|
|
|
|
|
|
|
|
if (match_str.is_empty()) {
|
|
@@ -746,7 +745,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_replace)
|
|
|
|
|
|
if (!capture.is_undefined()) {
|
|
|
|
|
|
- capture = PrimitiveString::create(vm, TRY(capture.to_byte_string(vm)));
|
|
|
+ capture = PrimitiveString::create(vm, TRY(capture.to_string(vm)));
|
|
|
}
|
|
|
|
|
|
|
|
@@ -810,13 +809,13 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_replace)
|
|
|
|
|
|
|
|
|
if (next_source_position >= string.length_in_code_units())
|
|
|
- return PrimitiveString::create(vm, accumulated_result.to_byte_string());
|
|
|
+ return PrimitiveString::create(vm, accumulated_result.to_string_without_validation());
|
|
|
|
|
|
|
|
|
auto substring = string.substring_view(next_source_position);
|
|
|
accumulated_result.append(substring);
|
|
|
|
|
|
- return PrimitiveString::create(vm, accumulated_result.to_byte_string());
|
|
|
+ return PrimitiveString::create(vm, accumulated_result.to_string_without_validation());
|
|
|
}
|
|
|
|
|
|
|
|
@@ -901,7 +900,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_split)
|
|
|
|
|
|
|
|
|
auto flags_value = TRY(regexp_object->get(vm.names.flags));
|
|
|
- auto flags = TRY(flags_value.to_byte_string(vm));
|
|
|
+ auto flags = TRY(flags_value.to_string(vm));
|
|
|
|
|
|
|
|
|
|
|
@@ -909,7 +908,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_split)
|
|
|
|
|
|
|
|
|
|
|
|
- auto new_flags = flags.find('y').has_value() ? move(flags) : ByteString::formatted("{}y", flags);
|
|
|
+ auto new_flags = flags.bytes_as_string_view().find('y').has_value() ? move(flags) : MUST(String::formatted("{}y", flags));
|
|
|
|
|
|
|
|
|
auto splitter = TRY(construct(vm, *constructor, regexp_object, PrimitiveString::create(vm, move(new_flags))));
|
|
@@ -1066,11 +1065,11 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::to_string)
|
|
|
|
|
|
|
|
|
auto source_attr = TRY(regexp_object->get(vm.names.source));
|
|
|
- auto pattern = TRY(source_attr.to_byte_string(vm));
|
|
|
+ auto pattern = TRY(source_attr.to_string(vm));
|
|
|
|
|
|
|
|
|
auto flags_attr = TRY(regexp_object->get(vm.names.flags));
|
|
|
- auto flags = TRY(flags_attr.to_byte_string(vm));
|
|
|
+ auto flags = TRY(flags_attr.to_string(vm));
|
|
|
|
|
|
|
|
|
|