Просмотр исходного кода

js: Fix pretty-printing of RegExp objects

Regressed in b7e5f08.

Use the newly available RegExpObject::escape_regexp_pattern() instead of
attempting to call the RegExp.prototype.source accessor getter directly.
Linus Groh 3 лет назад
Родитель
Сommit
fe802f5ff5
1 измененных файлов с 1 добавлено и 3 удалено
  1. 1 3
      Userland/Utilities/js.cpp

+ 1 - 3
Userland/Utilities/js.cpp

@@ -287,10 +287,8 @@ static void print_error(JS::Object const& object, HashTable<JS::Object*>& seen_o
 static void print_regexp_object(JS::Object const& object, HashTable<JS::Object*>&)
 {
     auto& regexp_object = static_cast<JS::RegExpObject const&>(object);
-    // Use RegExp.prototype.source rather than RegExpObject::pattern() so we get proper escaping
-    auto source = regexp_object.get_without_side_effects("source").to_primitive_string(object.global_object())->string();
     print_type("RegExp");
-    out(" \033[34;1m/{}/{}\033[0m", source, regexp_object.flags());
+    out(" \033[34;1m/{}/{}\033[0m", regexp_object.escape_regexp_pattern(), regexp_object.flags());
 }
 
 static void print_proxy_object(JS::Object const& object, HashTable<JS::Object*>& seen_objects)