12 auto schemeEnd = uri.find(
"://");
15 result.
Scheme = uri.substr(0, schemeEnd);
16 uri.remove_prefix(schemeEnd + 3);
19 auto fragmentStart = uri.find(
'#');
22 result.
Fragment = uri.substr(fragmentStart + 1);
23 uri.remove_suffix(uri.size() - fragmentStart);
26 auto queryStart = uri.find(
'?');
29 result.
Query = uri.substr(queryStart + 1);
30 uri.remove_suffix(uri.size() - queryStart);
33 auto pathStart = uri.find(
'/');
36 result.
Path = uri.substr(pathStart + 1);
37 uri.remove_suffix(uri.size() - pathStart);
40 auto userInfoEnd = uri.find(
'@');
43 result.
UserInfo = uri.substr(0, userInfoEnd);
44 uri.remove_prefix(userInfoEnd + 1);
47 auto portStart = uri.find(
':');
50 result.
Port = uri.substr(portStart + 1);
51 uri.remove_suffix(uri.size() - portStart);
63 while (!query.empty())
65 const auto queryItemEnd = query.find(delimiter);
66 const auto queryItem = query.substr(0, queryItemEnd);
72 const auto queryItemValueStart = queryItem.find(
'=');
74 const auto queryItemValue = queryItem.substr(
76 queryItemValueStart + 1 :
79 const auto queryItemKey = queryItem.substr(
84 result.emplace(queryItemKey, queryItemValue);
QueryFields ParseUriQuery(std::string_view query, std::string_view delimiter) noexcept
Parses URI query and returns QueryFields structure with parsed fields.
UriFields ParseUri(std::string_view uri) noexcept
std::unordered_map< std::string_view, std::string_view > QueryFields
constexpr size_t npos(-1)
std::string_view UserInfo
std::string_view Fragment