src/detail/effective_port.cpp

100.0% Lines (10/10) 100.0% List of functions (1/1) 100.0% Branches (12/12)
effective_port.cpp
f(x) Functions (1)
Line Branch TLA Hits Source Code
1 //
2 // Copyright (c) 2026 Mohammad Nejati
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 //
7 // Official repository: https://github.com/cppalliance/burl
8 //
9
10 #include "effective_port.hpp"
11
12 namespace boost
13 {
14 namespace burl
15 {
16 namespace detail
17 {
18
19 std::string_view
20 57x effective_port(const urls::url_view& url) noexcept
21 {
22
2/2
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 38 times.
57x if(url.has_port())
23 19x return url.port();
24
25
2/2
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 8 times.
38x if(url.scheme() == "https")
26 30x return "443";
27
28
2/2
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4 times.
8x if(url.scheme() == "http")
29 4x return "80";
30
31
6/6
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1 time.
✓ Branch 6 taken 1 time.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 2 times.
4x if(url.scheme() == "socks5" || url.scheme() == "socks5h")
32 2x return "1080";
33
34 2x return {};
35 }
36
37 } // namespace detail
38 } // namespace burl
39 } // namespace boost
40