LibWebView: Return a ByteString from WebView::url_text_to_copy

The result is currently only used as a StringView, but a future commit
will place the result in Web::Clipboard::SystemClipboardRepresentation,
which requires a ByteString (there's no UTF-8 clipboard requirement).
This commit is contained in:
Timothy Flynn 2025-09-02 12:44:34 -04:00 committed by Tim Flynn
commit 171937cc72
Notes: github-actions[bot] 2025-09-11 18:25:41 +00:00
2 changed files with 5 additions and 7 deletions

View file

@ -176,16 +176,14 @@ URLType url_type(URL::URL const& url)
return URLType::Other;
}
String url_text_to_copy(URL::URL const& url)
ByteString url_text_to_copy(URL::URL const& url)
{
auto url_text = url.to_string();
auto url_text = url.to_byte_string();
if (url.scheme() == "mailto"sv)
return MUST(url_text.substring_from_byte_offset("mailto:"sv.length()));
return url_text.substring("mailto:"sv.length());
if (url.scheme() == "tel"sv)
return MUST(url_text.substring_from_byte_offset("tel:"sv.length()));
return url_text.substring("tel:"sv.length());
return url_text;
}

View file

@ -35,6 +35,6 @@ enum class URLType {
Other,
};
WEBVIEW_API URLType url_type(URL::URL const&);
WEBVIEW_API String url_text_to_copy(URL::URL const&);
WEBVIEW_API ByteString url_text_to_copy(URL::URL const&);
}