Everywhere: Remove some use of the URL constructors

These make it too easy to construct an invalid URL, which makes it
difficult to remove the valid state of URL - which this API relies
on.
This commit is contained in:
Shannon Booth 2025-02-16 14:45:52 +13:00 committed by Tim Flynn
parent 2823ac92d0
commit d62cf0a807
Notes: github-actions[bot] 2025-02-19 13:02:46 +00:00
11 changed files with 341 additions and 329 deletions

View file

@ -5,6 +5,7 @@
*/
#include "ProxyMappings.h"
#include <LibURL/Parser.h>
Web::ProxyMappings& Web::ProxyMappings::the()
{
@ -17,7 +18,12 @@ Core::ProxyData Web::ProxyMappings::proxy_for_url(URL::URL const& url) const
auto url_string = url.to_byte_string();
for (auto& it : m_mappings) {
if (url_string.matches(it.key)) {
auto result = Core::ProxyData::parse_url(m_proxies[it.value]);
auto maybe_url = URL::Parser::basic_parse(m_proxies[it.value]);
if (!maybe_url.has_value()) {
dbgln("Failed to parse proxy URL: {}", m_proxies[it.value]);
continue;
}
auto result = Core::ProxyData::parse_url(maybe_url.value());
if (result.is_error()) {
dbgln("Failed to parse proxy URL: {}", m_proxies[it.value]);
continue;