1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-11 10:18:15 +09:00

UI/Qt: Do not rely on the URL implicit constructors

This commit is contained in:
Shannon Booth 2025-02-22 21:51:15 +13:00 committed by Tim Flynn
parent 0f495421f1
commit 3fb9c37783
Notes: github-actions[bot] 2025-03-04 21:26:06 +00:00
6 changed files with 21 additions and 11 deletions

View file

@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibURL/Parser.h>
#include <UI/Qt/StringUtils.h>
AK::ByteString ak_byte_string_from_qstring(QString const& qstring)
@ -23,13 +24,13 @@ QString qstring_from_ak_string(StringView ak_string)
return QString::fromUtf8(ak_string.characters_without_null_termination(), static_cast<qsizetype>(ak_string.length()));
}
URL::URL ak_url_from_qstring(QString const& qstring)
Optional<URL::URL> ak_url_from_qstring(QString const& qstring)
{
auto utf8_data = qstring.toUtf8();
return URL::URL(StringView(utf8_data.data(), utf8_data.size()));
return URL::Parser::basic_parse(StringView(utf8_data.data(), utf8_data.size()));
}
URL::URL ak_url_from_qurl(QUrl const& qurl)
{
return ak_url_from_qstring(qurl.toString());
return ak_url_from_qstring(qurl.toString()).value();
}