From c03c0ec900f259519cea1f44585b46944a29f3c5 Mon Sep 17 00:00:00 2001 From: Kenneth Myhra Date: Sat, 17 Jun 2023 09:15:40 +0200 Subject: [PATCH] AK: Add URL::to_string() returning a String For convenience wire up a to_string() method which returns a new String. --- AK/URL.cpp | 5 +++++ AK/URL.h | 1 + 2 files changed, 6 insertions(+) diff --git a/AK/URL.cpp b/AK/URL.cpp index c50aa6a5d0..5dfbfa915a 100644 --- a/AK/URL.cpp +++ b/AK/URL.cpp @@ -388,6 +388,11 @@ DeprecatedString URL::serialize_for_display() const return builder.to_deprecated_string(); } +ErrorOr URL::to_string() const +{ + return String::from_deprecated_string(serialize()); +} + // https://html.spec.whatwg.org/multipage/origin.html#ascii-serialisation-of-an-origin // https://url.spec.whatwg.org/#concept-url-origin DeprecatedString URL::serialize_origin() const diff --git a/AK/URL.h b/AK/URL.h index a71533b51d..744239d77f 100644 --- a/AK/URL.h +++ b/AK/URL.h @@ -99,6 +99,7 @@ public: DeprecatedString serialize(ExcludeFragment = ExcludeFragment::No) const; DeprecatedString serialize_for_display() const; DeprecatedString to_deprecated_string() const { return serialize(); } + ErrorOr to_string() const; // HTML origin DeprecatedString serialize_origin() const;