url
url copied to clipboard
parse_unicode_url function
trafficstars
We should have a function to handle unicode urls:
result<url> parse_unicode_url(...)
To convert to a valid URL, the host would be converted with punycode, and other components would percent-escape when possible. Errors are still possible.
We can identify components by identifying possible delimiters (like urls::format does) or we can provide functions that create a URL from its components:
result<url>
make_url(
string_view scheme,
utf8_string_view authority,
utf8_string_view path,
utf8_string_view query,
utf8_string_view fragment)
{
url u;
u.reserve(...);
u.set_scheme(scheme);
u.set_authority(authority);
u.set_path(path);
// ...
}
result<url>
make_iri(
string_view scheme,
utf8_string_view authority,
utf8_string_view path,
utf8_string_view query,
utf8_string_view fragment)
{
url u;
u.reserve(...);
u.set_scheme(scheme);
u.set_authority(detail::parse_punycode(authority));
u.set_path(detail::pct_encode(path));
// ...
}