Coverage Report

Created: 2025-11-16 07:46

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/serenity/Userland/Libraries/LibWeb/Loader/ProxyMappings.cpp
Line
Count
Source
1
/*
2
 * Copyright (c) 2022, Ali Mohammad Pur <mpfard@serenityos.org>
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#include "ProxyMappings.h"
8
9
Web::ProxyMappings& Web::ProxyMappings::the()
10
0
{
11
0
    static ProxyMappings instance {};
12
0
    return instance;
13
0
}
14
15
Core::ProxyData Web::ProxyMappings::proxy_for_url(URL::URL const& url) const
16
0
{
17
0
    auto url_string = url.to_byte_string();
18
0
    for (auto& it : m_mappings) {
19
0
        if (url_string.matches(it.key)) {
20
0
            auto result = Core::ProxyData::parse_url(m_proxies[it.value]);
21
0
            if (result.is_error()) {
22
0
                dbgln("Failed to parse proxy URL: {}", m_proxies[it.value]);
23
0
                continue;
24
0
            }
25
0
            return result.release_value();
26
0
        }
27
0
    }
28
29
0
    return {};
30
0
}
31
32
void Web::ProxyMappings::set_mappings(Vector<ByteString> proxies, OrderedHashMap<ByteString, size_t> mappings)
33
0
{
34
0
    m_proxies = move(proxies);
35
0
    m_mappings = move(mappings);
36
37
0
    dbgln("Proxy mappings updated: proxies: {}", m_proxies);
38
0
}