| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) | ||
| 3 | // Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com) | ||
| 4 | // | ||
| 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) | ||
| 7 | // | ||
| 8 | // Official repository: https://github.com/CPPAlliance/url | ||
| 9 | // | ||
| 10 | |||
| 11 | |||
| 12 | #include <boost/url/detail/config.hpp> | ||
| 13 | #include <boost/url/parse_query.hpp> | ||
| 14 | #include <boost/url/rfc/query_rule.hpp> | ||
| 15 | #include <boost/url/grammar/parse.hpp> | ||
| 16 | |||
| 17 | #include <boost/url/error.hpp> | ||
| 18 | |||
| 19 | namespace boost { | ||
| 20 | namespace urls { | ||
| 21 | |||
| 22 | system::result<params_encoded_view> | ||
| 23 | 137 | parse_query(core::string_view s) noexcept | |
| 24 | { | ||
| 25 | // Handle empty strings differently. | ||
| 26 | // We produce {}, versus empty but | ||
| 27 | // present query in URL (e.g. "http:?") | ||
| 28 | // which produces {{"", none}}. | ||
| 29 |
2/2✓ Branch 1 taken 8 times.
✓ Branch 2 taken 129 times.
|
137 | if(s.empty()) |
| 30 | 8 | return params_encoded_view( | |
| 31 | 16 | detail::query_ref( | |
| 32 | 8 | s.data(), 0, 0)); | |
| 33 | 129 | auto rv = grammar::parse(s, query_rule); | |
| 34 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 2 taken 117 times.
|
129 | if(! rv) |
| 35 | 12 | return rv.error(); | |
| 36 | 117 | return params_encoded_view( | |
| 37 | 234 | detail::query_ref( | |
| 38 | 234 | s, s.size(), rv->size())); | |
| 39 | } | ||
| 40 | |||
| 41 | } // urls | ||
| 42 | } // boost | ||
| 43 | |||
| 44 |