mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:48:12 +00:00

We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
38 lines
1,007 B
C++
38 lines
1,007 B
C++
/*
|
|
* Copyright (c) 2022, Ali Mohammad Pur <mpfard@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include "ProxyMappings.h"
|
|
|
|
Web::ProxyMappings& Web::ProxyMappings::the()
|
|
{
|
|
static ProxyMappings instance {};
|
|
return instance;
|
|
}
|
|
|
|
Core::ProxyData Web::ProxyMappings::proxy_for_url(AK::URL const& url) const
|
|
{
|
|
auto url_string = url.to_string();
|
|
for (auto& it : m_mappings) {
|
|
if (url_string.matches(it.key)) {
|
|
auto result = Core::ProxyData::parse_url(m_proxies[it.value]);
|
|
if (result.is_error()) {
|
|
dbgln("Failed to parse proxy URL: {}", m_proxies[it.value]);
|
|
continue;
|
|
}
|
|
return result.release_value();
|
|
}
|
|
}
|
|
|
|
return {};
|
|
}
|
|
|
|
void Web::ProxyMappings::set_mappings(Vector<DeprecatedString> proxies, OrderedHashMap<DeprecatedString, size_t> mappings)
|
|
{
|
|
m_proxies = move(proxies);
|
|
m_mappings = move(mappings);
|
|
|
|
dbgln("Proxy mappings updated: proxies: {}", m_proxies);
|
|
}
|