diff --git a/AK/URL.cpp b/AK/URL.cpp index b2382ef6b19..be47f41314d 100644 --- a/AK/URL.cpp +++ b/AK/URL.cpp @@ -80,7 +80,7 @@ static DeprecatedString deprecated_string_percent_encode(DeprecatedString const& return URL::percent_encode(input.view(), set, space_as_plus); } -void URL::set_scheme(DeprecatedString scheme) +void URL::set_scheme(String scheme) { m_scheme = move(scheme); m_valid = compute_validity(); @@ -213,7 +213,7 @@ URL URL::create_with_file_scheme(DeprecatedString const& path, DeprecatedString return {}; URL url; - url.set_scheme("file"); + url.set_scheme("file"_string); // NOTE: If the hostname is localhost (or null, which implies localhost), it should be set to the empty string. // This is because a file URL always needs a non-null hostname. url.set_host(hostname.is_null() || hostname == "localhost" ? String {} : String::from_deprecated_string(hostname).release_value_but_fixme_should_propagate_errors()); @@ -229,7 +229,7 @@ URL URL::create_with_help_scheme(DeprecatedString const& path, DeprecatedString LexicalPath lexical_path(path); URL url; - url.set_scheme("help"); + url.set_scheme("help"_string); // NOTE: If the hostname is localhost (or null, which implies localhost), it should be set to the empty string. // This is because a file URL always needs a non-null hostname. url.set_host(hostname.is_null() || hostname == "localhost" ? String {} : String::from_deprecated_string(hostname).release_value_but_fixme_should_propagate_errors()); @@ -255,7 +255,7 @@ URL URL::create_with_data(StringView mime_type, StringView payload, bool is_base { URL url; url.set_cannot_be_a_base_url(true); - url.set_scheme("data"sv); + url.set_scheme("data"_string); StringBuilder builder; builder.append(mime_type); diff --git a/AK/URL.h b/AK/URL.h index 2dab5cf6784..1f5c0305ed3 100644 --- a/AK/URL.h +++ b/AK/URL.h @@ -76,7 +76,7 @@ public: Yes, No }; - DeprecatedString const& scheme() const { return m_scheme; } + String const& scheme() const { return m_scheme; } ErrorOr username() const; ErrorOr password() const; Host const& host() const { return m_host; } @@ -97,7 +97,7 @@ public: bool includes_credentials() const { return !m_username.is_empty() || !m_password.is_empty(); } bool is_special() const { return is_special_scheme(m_scheme); } - void set_scheme(DeprecatedString); + void set_scheme(String); ErrorOr set_username(StringView); ErrorOr set_password(StringView); void set_host(Host); @@ -163,7 +163,7 @@ private: bool m_valid { false }; // A URL’s scheme is an ASCII string that identifies the type of URL and can be used to dispatch a URL for further processing after parsing. It is initially the empty string. - DeprecatedString m_scheme; + String m_scheme; // A URL’s username is an ASCII string identifying a username. It is initially the empty string. String m_username; diff --git a/AK/URLParser.cpp b/AK/URLParser.cpp index d6b3ede51dd..dab9c292432 100644 --- a/AK/URLParser.cpp +++ b/AK/URLParser.cpp @@ -850,7 +850,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional const& base_url, } // 2. Set url’s scheme to buffer. - url->m_scheme = buffer.to_deprecated_string(); + url->m_scheme = buffer.to_string().release_value_but_fixme_should_propagate_errors(); // 3. If state override is given, then: if (state_override.has_value()) { @@ -1281,7 +1281,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional const& base_url, // -> file state, https://url.spec.whatwg.org/#file-state case State::File: // 1. Set url’s scheme to "file". - url->m_scheme = "file"; + url->m_scheme = String::from_utf8("file"sv).release_value_but_fixme_should_propagate_errors(); // 2. Set url’s host to the empty string. url->m_host = String {}; diff --git a/Ladybird/Qt/LocationEdit.cpp b/Ladybird/Qt/LocationEdit.cpp index ea83a44836f..5fbad391de5 100644 --- a/Ladybird/Qt/LocationEdit.cpp +++ b/Ladybird/Qt/LocationEdit.cpp @@ -50,7 +50,7 @@ void LocationEdit::highlight_location() QList attributes; if (url.is_valid() && !hasFocus()) { if (url.scheme() == "http" || url.scheme() == "https" || url.scheme() == "gemini") { - int host_start = (url.scheme().length() + 3) - cursorPosition(); + int host_start = (url.scheme().bytes_as_string_view().length() + 3) - cursorPosition(); auto host_length = url.serialized_host().release_value_but_fixme_should_propagate_errors().bytes().size(); // FIXME: Maybe add a generator to use https://publicsuffix.org/list/public_suffix_list.dat @@ -79,7 +79,7 @@ void LocationEdit::highlight_location() attributes.append({ QInputMethodEvent::TextFormat, -cursorPosition(), - static_cast(url.scheme().length() + 3), + static_cast(url.scheme().bytes_as_string_view().length() + 3), schemeFormat, }); } diff --git a/Ladybird/Qt/RequestManagerQt.cpp b/Ladybird/Qt/RequestManagerQt.cpp index cce30fc8f49..e05fc95f8c9 100644 --- a/Ladybird/Qt/RequestManagerQt.cpp +++ b/Ladybird/Qt/RequestManagerQt.cpp @@ -26,7 +26,7 @@ void RequestManagerQt::reply_finished(QNetworkReply* reply) RefPtr RequestManagerQt::start_request(DeprecatedString const& method, AK::URL const& url, HashMap const& request_headers, ReadonlyBytes request_body, Core::ProxyData const& proxy) { - if (!url.scheme().is_one_of_ignoring_ascii_case("http"sv, "https"sv)) { + if (!url.scheme().bytes_as_string_view().is_one_of_ignoring_ascii_case("http"sv, "https"sv)) { return nullptr; } auto request_or_error = Request::create(*m_qnam, method, url, request_headers, request_body, proxy); diff --git a/Userland/Applications/Assistant/Providers.cpp b/Userland/Applications/Assistant/Providers.cpp index 98e34199c01..98856afe441 100644 --- a/Userland/Applications/Assistant/Providers.cpp +++ b/Userland/Applications/Assistant/Providers.cpp @@ -247,7 +247,7 @@ void URLProvider::query(DeprecatedString const& query, Function() || url.host() == String {}) url.set_host(String::from_deprecated_string(query).release_value_but_fixme_should_propagate_errors()); if (url.path_segment_count() == 0) diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.cpp b/Userland/Applications/Spreadsheet/Spreadsheet.cpp index 44e09e1424d..1e94d97c2f0 100644 --- a/Userland/Applications/Spreadsheet/Spreadsheet.cpp +++ b/Userland/Applications/Spreadsheet/Spreadsheet.cpp @@ -754,7 +754,7 @@ DeprecatedString Position::to_cell_identifier(Sheet const& sheet) const URL Position::to_url(Sheet const& sheet) const { URL url; - url.set_scheme("spreadsheet"); + url.set_scheme("spreadsheet"_string); url.set_host("cell"_string); url.set_paths({ DeprecatedString::number(getpid()) }); url.set_fragment(to_cell_identifier(sheet)); diff --git a/Userland/DevTools/SQLStudio/MainWidget.cpp b/Userland/DevTools/SQLStudio/MainWidget.cpp index b0dce5cf098..cf788bbcb8e 100644 --- a/Userland/DevTools/SQLStudio/MainWidget.cpp +++ b/Userland/DevTools/SQLStudio/MainWidget.cpp @@ -486,7 +486,7 @@ void MainWidget::drop_event(GUI::DropEvent& drop_event) for (auto& url : urls) { auto& scheme = url.scheme(); - if (!scheme.equals_ignoring_ascii_case("file"sv)) + if (!scheme.bytes_as_string_view().equals_ignoring_ascii_case("file"sv)) continue; auto lexical_path = LexicalPath(url.serialize_path()); diff --git a/Userland/Libraries/LibGUI/TextBox.cpp b/Userland/Libraries/LibGUI/TextBox.cpp index 9f50acc16b4..48dd48e14c1 100644 --- a/Userland/Libraries/LibGUI/TextBox.cpp +++ b/Userland/Libraries/LibGUI/TextBox.cpp @@ -180,7 +180,7 @@ void UrlBox::highlight_url() if (url.is_valid() && !is_focused()) { if (url.scheme() == "http" || url.scheme() == "https" || url.scheme() == "gemini") { auto serialized_host = url.serialized_host().release_value_but_fixme_should_propagate_errors().to_deprecated_string(); - auto host_start = url.scheme().length() + 3; + auto host_start = url.scheme().bytes_as_string_view().length() + 3; auto host_length = serialized_host.length(); // FIXME: Maybe add a generator to use https://publicsuffix.org/list/public_suffix_list.dat @@ -208,7 +208,7 @@ void UrlBox::highlight_url() Gfx::TextAttributes scheme_format; scheme_format.color = palette().color(Gfx::ColorRole::PlaceholderText); spans.append({ - { { 0, 0 }, { 0, url.scheme().length() + 3 } }, + { { 0, 0 }, { 0, url.scheme().bytes_as_string_view().length() + 3 } }, scheme_format, }); } diff --git a/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp b/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp index b61f747539d..7afb5cd82bf 100644 --- a/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp @@ -266,7 +266,7 @@ WebIDL::ExceptionOr>> main_fetch(JS:: && false ) { - request->current_url().set_scheme("https"sv); + request->current_url().set_scheme("https"_string); } JS::SafeFunction>()> get_response = [&realm, &vm, &fetch_params, request]() -> WebIDL::ExceptionOr> { diff --git a/Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp b/Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp index bc534a3984a..a9a6a746463 100644 --- a/Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp +++ b/Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp @@ -31,7 +31,7 @@ WebIDL::ExceptionOr WorkerLocation::protocol() const { auto& vm = realm().vm(); // The protocol getter steps are to return this's WorkerGlobalScope object's url's scheme, followed by ":". - return TRY_OR_THROW_OOM(vm, String::formatted("{}:", m_global_scope->url().scheme().view())); + return TRY_OR_THROW_OOM(vm, String::formatted("{}:", m_global_scope->url().scheme())); } // https://html.spec.whatwg.org/multipage/workers.html#dom-workerlocation-host diff --git a/Userland/Libraries/LibWeb/URL/URL.cpp b/Userland/Libraries/LibWeb/URL/URL.cpp index 370826c6ef8..1c24367c508 100644 --- a/Userland/Libraries/LibWeb/URL/URL.cpp +++ b/Userland/Libraries/LibWeb/URL/URL.cpp @@ -513,14 +513,14 @@ HTML::Origin url_origin(AK::URL const& url) // -> "wss" if (url.scheme().is_one_of("ftp"sv, "http"sv, "https"sv, "ws"sv, "wss"sv)) { // Return the tuple origin (url’s scheme, url’s host, url’s port, null). - return HTML::Origin(url.scheme(), url.host(), url.port().value_or(0)); + return HTML::Origin(url.scheme().to_deprecated_string(), url.host(), url.port().value_or(0)); } // -> "file" if (url.scheme() == "file"sv) { // Unfortunate as it is, this is left as an exercise to the reader. When in doubt, return a new opaque origin. // Note: We must return an origin with the `file://' protocol for `file://' iframes to work from `file://' pages. - return HTML::Origin(url.scheme(), String {}, 0); + return HTML::Origin(url.scheme().to_deprecated_string(), String {}, 0); } // -> Otherwise diff --git a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp index d5050e70e38..e1ace23d0d8 100644 --- a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp +++ b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp @@ -69,10 +69,10 @@ WebIDL::ExceptionOr> WebSocket::construct_impl(JS::R // 4. If urlRecord’s scheme is "http", then set urlRecord’s scheme to "ws". if (url_record.scheme() == "http"sv) - url_record.set_scheme("ws"sv); + url_record.set_scheme("ws"_string); // 5. Otherwise, if urlRecord’s scheme is "https", set urlRecord’s scheme to "wss". else if (url_record.scheme() == "https"sv) - url_record.set_scheme("wss"sv); + url_record.set_scheme("wss"_string); // 6. If urlRecord’s scheme is not "ws" or "wss", then throw a "SyntaxError" DOMException. if (!url_record.scheme().is_one_of("ws"sv, "wss"sv)) diff --git a/Userland/Libraries/LibWebSocket/ConnectionInfo.cpp b/Userland/Libraries/LibWebSocket/ConnectionInfo.cpp index cd3a29d73c4..dfae4baf477 100644 --- a/Userland/Libraries/LibWebSocket/ConnectionInfo.cpp +++ b/Userland/Libraries/LibWebSocket/ConnectionInfo.cpp @@ -17,7 +17,7 @@ bool ConnectionInfo::is_secure() const { // RFC 6455 Section 3 : // The URI is called "secure" if the scheme component matches "wss" case-insensitively. - return m_url.scheme().equals_ignoring_ascii_case("wss"sv); + return m_url.scheme().bytes_as_string_view().equals_ignoring_ascii_case("wss"sv); } DeprecatedString ConnectionInfo::resource_name() const diff --git a/Userland/Services/LaunchServer/Launcher.cpp b/Userland/Services/LaunchServer/Launcher.cpp index f3720d84a03..295d17ab6f1 100644 --- a/Userland/Services/LaunchServer/Launcher.cpp +++ b/Userland/Services/LaunchServer/Launcher.cpp @@ -146,8 +146,8 @@ Vector Launcher::handlers_for_url(const URL& url) return true; }); } else { - for_each_handler(url.scheme(), m_protocol_handlers, [&](auto const& handler) -> bool { - if (handler.handler_type != Handler::Type::Default || handler.protocols.contains(url.scheme())) { + for_each_handler(url.scheme().to_deprecated_string(), m_protocol_handlers, [&](auto const& handler) -> bool { + if (handler.handler_type != Handler::Type::Default || handler.protocols.contains(url.scheme().to_deprecated_string())) { handlers.append(handler.executable); return true; } @@ -166,8 +166,8 @@ Vector Launcher::handlers_with_details_for_url(const URL& url) return true; }); } else { - for_each_handler(url.scheme(), m_protocol_handlers, [&](auto const& handler) -> bool { - if (handler.handler_type != Handler::Type::Default || handler.protocols.contains(url.scheme())) { + for_each_handler(url.scheme().to_deprecated_string(), m_protocol_handlers, [&](auto const& handler) -> bool { + if (handler.handler_type != Handler::Type::Default || handler.protocols.contains(url.scheme().to_deprecated_string())) { handlers.append(handler.to_details_str()); return true; } @@ -194,7 +194,7 @@ bool Launcher::open_url(const URL& url, DeprecatedString const& handler_name) if (url.scheme() == "file") return open_file_url(url); - return open_with_user_preferences(m_protocol_handlers, url.scheme(), { url.to_deprecated_string() }); + return open_with_user_preferences(m_protocol_handlers, url.scheme().to_deprecated_string(), { url.to_deprecated_string() }); } bool Launcher::open_with_handler_name(const URL& url, DeprecatedString const& handler_name) diff --git a/Userland/Services/RequestServer/ConnectionFromClient.cpp b/Userland/Services/RequestServer/ConnectionFromClient.cpp index 0ca1736eed2..a30e1c71b4a 100644 --- a/Userland/Services/RequestServer/ConnectionFromClient.cpp +++ b/Userland/Services/RequestServer/ConnectionFromClient.cpp @@ -42,7 +42,7 @@ Messages::RequestServer::StartRequestResponse ConnectionFromClient::start_reques dbgln("StartRequest: Invalid URL requested: '{}'", url); return { -1, Optional {} }; } - auto* protocol = Protocol::find_by_name(url.scheme()); + auto* protocol = Protocol::find_by_name(url.scheme().to_deprecated_string()); if (!protocol) { dbgln("StartRequest: No protocol handler for URL: '{}'", url); return { -1, Optional {} };