92.59% Lines (25/27)
100.00% Functions (1/1)
| TLA | Baseline | Branch | ||||||
|---|---|---|---|---|---|---|---|---|
| Line | Hits | Code | Line | Hits | Code | |||
| 1 | // | 1 | // | |||||
| 2 | // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) | 2 | // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) | |||||
| 3 | // Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com) | 3 | // Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com) | |||||
| 4 | // | 4 | // | |||||
| 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | |||||
| 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |||||
| 7 | // | 7 | // | |||||
| 8 | // Official repository: https://github.com/boostorg/url | 8 | // Official repository: https://github.com/boostorg/url | |||||
| 9 | // | 9 | // | |||||
| 10 | 10 | |||||||
| 11 | #ifndef BOOST_URL_RFC_IMPL_AUTHORITY_RULE_HPP | 11 | #ifndef BOOST_URL_RFC_IMPL_AUTHORITY_RULE_HPP | |||||
| 12 | #define BOOST_URL_RFC_IMPL_AUTHORITY_RULE_HPP | 12 | #define BOOST_URL_RFC_IMPL_AUTHORITY_RULE_HPP | |||||
| 13 | 13 | |||||||
| 14 | #include <boost/url/detail/config.hpp> | 14 | #include <boost/url/detail/config.hpp> | |||||
| 15 | #include <boost/url/grammar/delim_rule.hpp> | 15 | #include <boost/url/grammar/delim_rule.hpp> | |||||
| 16 | #include <boost/url/grammar/optional_rule.hpp> | 16 | #include <boost/url/grammar/optional_rule.hpp> | |||||
| 17 | #include <boost/url/grammar/parse.hpp> | 17 | #include <boost/url/grammar/parse.hpp> | |||||
| 18 | #include <boost/url/grammar/tuple_rule.hpp> | 18 | #include <boost/url/grammar/tuple_rule.hpp> | |||||
| 19 | #include <boost/url/rfc/detail/host_rule.hpp> | 19 | #include <boost/url/rfc/detail/host_rule.hpp> | |||||
| 20 | #include <boost/url/rfc/detail/port_rule.hpp> | 20 | #include <boost/url/rfc/detail/port_rule.hpp> | |||||
| 21 | #include <boost/url/rfc/detail/userinfo_rule.hpp> | 21 | #include <boost/url/rfc/detail/userinfo_rule.hpp> | |||||
| 22 | 22 | |||||||
| 23 | namespace boost { | 23 | namespace boost { | |||||
| 24 | namespace urls { | 24 | namespace urls { | |||||
| 25 | 25 | |||||||
| 26 | BOOST_URL_CXX20_CONSTEXPR_OR_INLINE | 26 | BOOST_URL_CXX20_CONSTEXPR_OR_INLINE | |||||
| 27 | auto | 27 | auto | |||||
| HITCBC | 28 | 6645 | implementation_defined::authority_rule_t:: | 28 | 6645 | implementation_defined::authority_rule_t:: | ||
| 29 | parse( | 29 | parse( | |||||
| 30 | char const*& it, | 30 | char const*& it, | |||||
| 31 | char const* const end | 31 | char const* const end | |||||
| 32 | ) const noexcept -> | 32 | ) const noexcept -> | |||||
| 33 | system::result<value_type> | 33 | system::result<value_type> | |||||
| 34 | { | 34 | { | |||||
| HITCBC | 35 | 6645 | detail::url_impl u(detail::url_impl::from::authority); | 35 | 6645 | detail::url_impl u(detail::url_impl::from::authority); | ||
| HITCBC | 36 | 6645 | u.cs_ = it; | 36 | 6645 | u.cs_ = it; | ||
| 37 | 37 | |||||||
| 38 | // [ userinfo "@" ] | 38 | // [ userinfo "@" ] | |||||
| 39 | { | 39 | { | |||||
| 40 | auto rv = grammar::parse( | 40 | auto rv = grammar::parse( | |||||
| 41 | it, end, | 41 | it, end, | |||||
| HITCBC | 42 | 6645 | grammar::optional_rule( | 42 | 6645 | grammar::optional_rule( | ||
| HITCBC | 43 | 6645 | grammar::tuple_rule( | 43 | 6645 | grammar::tuple_rule( | ||
| 44 | detail::userinfo_rule, | 44 | detail::userinfo_rule, | |||||
| HITCBC | 45 | 6645 | grammar::squelch( | 45 | 6645 | grammar::squelch( | ||
| HITCBC | 46 | 13290 | grammar::delim_rule('@'))))); | 46 | 13290 | grammar::delim_rule('@'))))); | ||
| HITCBC | 47 | 6645 | if(! rv) | 47 | 6645 | if(! rv) | ||
| MISUBC | 48 | ✗ | return rv.error(); | 48 | ✗ | return rv.error(); | ||
| HITCBC | 49 | 6645 | if(rv->has_value()) | 49 | 6645 | if(rv->has_value()) | ||
| 50 | { | 50 | { | |||||
| HITCBC | 51 | 137 | u.apply_userinfo( | 51 | 137 | u.apply_userinfo( | ||
| HITCBC | 52 | 423 | (*rv)->user, | 52 | 423 | (*rv)->user, | ||
| HITCBC | 53 | 423 | (*rv)->has_password | 53 | 423 | (*rv)->has_password | ||
| HITCBC | 54 | 286 | ? &(*rv)->password | 54 | 286 | ? &(*rv)->password | ||
| 55 | : nullptr); | 55 | : nullptr); | |||||
| 56 | } | 56 | } | |||||
| 57 | } | 57 | } | |||||
| 58 | 58 | |||||||
| 59 | // host | 59 | // host | |||||
| 60 | { | 60 | { | |||||
| HITCBC | 61 | 6645 | auto rv = grammar::parse( | 61 | 6645 | auto rv = grammar::parse( | ||
| 62 | it, end, detail::host_rule); | 62 | it, end, detail::host_rule); | |||||
| HITCBC | 63 | 6645 | if(! rv) | 63 | 6645 | if(! rv) | ||
| HITCBC | 64 | 32 | return rv.error(); | 64 | 32 | return rv.error(); | ||
| HITCBC | 65 | 6613 | u.apply_host(rv->host_type, | 65 | 6613 | u.apply_host(rv->host_type, | ||
| HITCBC | 66 | 6613 | rv->match, rv->addr); | 66 | 6613 | rv->match, rv->addr); | ||
| 67 | } | 67 | } | |||||
| 68 | 68 | |||||||
| 69 | // [ ":" port ] | 69 | // [ ":" port ] | |||||
| 70 | { | 70 | { | |||||
| HITCBC | 71 | 6613 | auto rv = grammar::parse( | 71 | 6613 | auto rv = grammar::parse( | ||
| 72 | it, end, detail::port_part_rule); | 72 | it, end, detail::port_part_rule); | |||||
| HITCBC | 73 | 6613 | if(! rv) | 73 | 6613 | if(! rv) | ||
| MISUBC | 74 | ✗ | return rv.error(); | 74 | ✗ | return rv.error(); | ||
| HITCBC | 75 | 6613 | if(rv->has_port) | 75 | 6613 | if(rv->has_port) | ||
| HITCBC | 76 | 756 | u.apply_port( | 76 | 756 | u.apply_port( | ||
| HITCBC | 77 | 378 | rv->port, | 77 | 378 | rv->port, | ||
| HITCBC | 78 | 378 | rv->port_number); | 78 | 378 | rv->port_number); | ||
| 79 | } | 79 | } | |||||
| 80 | 80 | |||||||
| HITCBC | 81 | 6613 | return authority_view(u); | 81 | 6613 | return authority_view(u); | ||
| 82 | } | 82 | } | |||||
| 83 | 83 | |||||||
| 84 | } // urls | 84 | } // urls | |||||
| 85 | } // boost | 85 | } // boost | |||||
| 86 | 86 | |||||||
| 87 | #endif | 87 | #endif | |||||