Skip to content

Commit c03c0ec

Browse files
kennethmyhraawesomekling
authored andcommitted
AK: Add URL::to_string() returning a String
For convenience wire up a to_string() method which returns a new String.
1 parent b264d29 commit c03c0ec

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

AK/URL.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,11 @@ DeprecatedString URL::serialize_for_display() const
388388
return builder.to_deprecated_string();
389389
}
390390

391+
ErrorOr<String> URL::to_string() const
392+
{
393+
return String::from_deprecated_string(serialize());
394+
}
395+
391396
// https://html.spec.whatwg.org/multipage/origin.html#ascii-serialisation-of-an-origin
392397
// https://url.spec.whatwg.org/#concept-url-origin
393398
DeprecatedString URL::serialize_origin() const

AK/URL.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class URL {
9999
DeprecatedString serialize(ExcludeFragment = ExcludeFragment::No) const;
100100
DeprecatedString serialize_for_display() const;
101101
DeprecatedString to_deprecated_string() const { return serialize(); }
102+
ErrorOr<String> to_string() const;
102103

103104
// HTML origin
104105
DeprecatedString serialize_origin() const;

0 commit comments

Comments
 (0)