100.00% Lines (23/23)
100.00% Functions (1/1)
| TLA | Baseline | Branch | ||||||
|---|---|---|---|---|---|---|---|---|
| Line | Hits | Code | Line | Hits | Code | |||
| 1 | // | 1 | // | |||||
| 2 | // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) | 2 | // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) | |||||
| 3 | // Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com) | 3 | // Copyright (c) 2022 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 | 11 | |||||||
| 12 | #include <boost/url/detail/config.hpp> | 12 | #include <boost/url/detail/config.hpp> | |||||
| 13 | #include <boost/url/parse_path.hpp> | 13 | #include <boost/url/parse_path.hpp> | |||||
| 14 | #include <boost/url/error.hpp> | 14 | #include <boost/url/error.hpp> | |||||
| 15 | #include <boost/url/detail/path.hpp> | 15 | #include <boost/url/detail/path.hpp> | |||||
| 16 | #include <boost/url/grammar/parse.hpp> | 16 | #include <boost/url/grammar/parse.hpp> | |||||
| 17 | #include "boost/url/rfc/detail/path_rules.hpp" | 17 | #include "boost/url/rfc/detail/path_rules.hpp" | |||||
| 18 | 18 | |||||||
| 19 | namespace boost { | 19 | namespace boost { | |||||
| 20 | namespace urls { | 20 | namespace urls { | |||||
| 21 | 21 | |||||||
| 22 | system::result<segments_encoded_view> | 22 | system::result<segments_encoded_view> | |||||
| HITCBC | 23 | 3223 | parse_path(core::string_view s) noexcept | 23 | 3223 | parse_path(core::string_view s) noexcept | ||
| 24 | { | 24 | { | |||||
| HITCBC | 25 | 3223 | auto it = s.data(); | 25 | 3223 | auto it = s.data(); | ||
| HITCBC | 26 | 3223 | auto const end = it + s.size(); | 26 | 3223 | auto const end = it + s.size(); | ||
| HITCBC | 27 | 3223 | std::size_t dn = 0; | 27 | 3223 | std::size_t dn = 0; | ||
| HITCBC | 28 | 3223 | std::size_t nseg = 0; | 28 | 3223 | std::size_t nseg = 0; | ||
| HITCBC | 29 | 3223 | if( it != end && | 29 | 3223 | if( it != end && | ||
| HITCBC | 30 | 3215 | *it != '/') | 30 | 3215 | *it != '/') | ||
| HITCBC | 31 | 3124 | ++nseg; | 31 | 3124 | ++nseg; | ||
| HITCBC | 32 | 6975 | while(it != end) | 32 | 6975 | while(it != end) | ||
| 33 | { | 33 | { | |||||
| HITCBC | 34 | 6756 | if(*it == '/') | 34 | 6756 | if(*it == '/') | ||
| 35 | { | 35 | { | |||||
| HITCBC | 36 | 640 | ++it; | 36 | 640 | ++it; | ||
| HITCBC | 37 | 640 | ++dn; | 37 | 640 | ++dn; | ||
| HITCBC | 38 | 640 | ++nseg; | 38 | 640 | ++nseg; | ||
| HITCBC | 39 | 640 | continue; | 39 | 640 | continue; | ||
| 40 | } | 40 | } | |||||
| HITCBC | 41 | 6116 | auto rv = grammar::parse( | 41 | 6116 | auto rv = grammar::parse( | ||
| 42 | it, end, detail::segment_rule); | 42 | it, end, detail::segment_rule); | |||||
| HITCBC | 43 | 6116 | if(! rv) | 43 | 6116 | if(! rv) | ||
| HITCBC | 44 | 44 | return rv.error(); | 44 | 44 | return rv.error(); | ||
| HITCBC | 45 | 6072 | if(rv->empty()) | 45 | 6072 | if(rv->empty()) | ||
| 46 | { | 46 | { | |||||
| HITCBC | 47 | 2960 | BOOST_URL_RETURN_EC( | 47 | 2960 | BOOST_URL_RETURN_EC( | ||
| 48 | grammar::error::mismatch); | 48 | grammar::error::mismatch); | |||||
| 49 | } | 49 | } | |||||
| HITCBC | 50 | 3112 | dn += rv->decoded_size(); | 50 | 3112 | dn += rv->decoded_size(); | ||
| 51 | } | 51 | } | |||||
| 52 | // adjust nseg | 52 | // adjust nseg | |||||
| HITCBC | 53 | 219 | nseg = detail::path_segments(s, nseg); | 53 | 219 | nseg = detail::path_segments(s, nseg); | ||
| HITCBC | 54 | 219 | return segments_encoded_view( | 54 | 219 | return segments_encoded_view( | ||
| HITCBC | 55 | 438 | detail::path_ref(s, dn, nseg)); | 55 | 438 | detail::path_ref(s, dn, nseg)); | ||
| 56 | } | 56 | } | |||||
| 57 | 57 | |||||||
| 58 | } // urls | 58 | } // urls | |||||
| 59 | } // boost | 59 | } // boost | |||||
| 60 | 60 | |||||||