Sourcemeta Core 0.0.0
Loading...
Searching...
No Matches
uri.h
1#ifndef SOURCEMETA_CORE_URI_H_
2#define SOURCEMETA_CORE_URI_H_
3
4#ifndef SOURCEMETA_CORE_URI_EXPORT
5#include <sourcemeta/core/uri_export.h>
6#endif
7
8#include <sourcemeta/core/text.h>
9
10// NOLINTBEGIN(misc-include-cleaner)
11#include <sourcemeta/core/uri_error.h>
12// NOLINTEND(misc-include-cleaner)
13
14#include <array> // std::array
15#include <concepts> // std::convertible_to, std::same_as
16#include <cstddef> // std::size_t, std::ptrdiff_t
17#include <cstdint> // std::uint8_t, std::uint32_t
18#include <filesystem> // std::filesystem
19#include <istream> // std::istream
20#include <iterator> // std::forward_iterator_tag
21#include <memory> // std::unique_ptr
22#include <optional> // std::optional
23#include <span> // std::span
24#include <string> // std::string
25#include <string_view> // std::string_view
26#include <type_traits> // std::is_same_v, std::remove_cvref_t
27#include <utility> // std::pair, std::forward
28#include <vector> // std::vector
29
39
40namespace sourcemeta::core {
41
44class SOURCEMETA_CORE_URI_EXPORT URI {
45public:
47 URI() = default;
48
50 URI(const URI &) = default;
51
53 URI(URI &&) noexcept = default;
54
56 auto operator=(const URI &) -> URI & = default;
57
59 auto operator=(URI &&) noexcept -> URI & = default;
60
68 template <typename T>
69 requires std::convertible_to<T, std::string_view> &&
70 (!std::is_same_v<std::decay_t<T>, URI>)
71 explicit URI(T &&input) {
72 this->parse(std::string_view{std::forward<T>(input)});
73 }
74
84 URI(std::istream &input);
85
95 [[nodiscard]] auto is_absolute() const noexcept -> bool;
96
106 [[nodiscard]] auto is_urn() const -> bool;
107
117 [[nodiscard]] auto is_tag() const -> bool;
118
128 [[nodiscard]] auto is_mailto() const -> bool;
129
139 [[nodiscard]] auto is_file() const -> bool;
140
151 [[nodiscard]] auto is_http() const -> bool;
152
163 [[nodiscard]] auto is_https() const -> bool;
164
174 [[nodiscard]] auto is_fragment_only() const -> bool;
175
185 [[nodiscard]] auto is_relative() const -> bool;
186
196 [[nodiscard]] auto is_ipv4() const -> bool;
197
207 [[nodiscard]] auto is_ipv6() const -> bool;
208
225 [[nodiscard]] auto is_loopback() const -> bool;
226
241 [[nodiscard]] auto is_localhost() const -> bool;
242
252 [[nodiscard]] auto empty() const -> bool;
253
264 [[nodiscard]] auto scheme() const -> std::optional<std::string_view>;
265
276 [[nodiscard]] auto host() const -> std::optional<std::string_view>;
277
290 [[nodiscard]] auto port() const -> std::optional<std::uint32_t>;
291
310 [[nodiscard]] auto authority() const -> std::optional<std::string>;
311
323 [[nodiscard]] auto path() const -> std::optional<std::string_view>;
324
337 auto path(const std::string &path) -> URI &;
338
351 auto path(std::string &&path) -> URI &;
352
366 auto append_path(std::string_view path) -> URI &;
367
381 auto append_path(const URI &reference) -> URI &;
382
398 auto append_path(URI &&reference) -> URI &;
399
411 auto extension(std::string &&extension) -> URI &;
412
423 [[nodiscard]] auto fragment() const -> std::optional<std::string_view>;
424
438 auto fragment(const std::string_view fragment) -> URI &;
439
451 auto unescaped_fragment(const std::string_view fragment) -> URI &;
452
468 class SOURCEMETA_CORE_URI_EXPORT Query {
469 public:
481 explicit Query(const std::string_view raw);
482
494 [[nodiscard]] auto raw() const -> std::string_view;
495
512 [[nodiscard]] auto at(const std::string_view name) const
513 -> std::optional<std::string_view>;
514
518 class SOURCEMETA_CORE_URI_EXPORT const_iterator {
519 public:
520 using iterator_category = std::forward_iterator_tag;
521 using value_type = std::pair<std::string_view, std::string_view>;
522 using difference_type = std::ptrdiff_t;
523 using reference = const value_type &;
524 using pointer = const value_type *;
525
526 const_iterator() = default;
527 const_iterator(const std::string_view raw, const std::size_t pair_start);
528
529 [[nodiscard]] auto operator*() const -> reference;
530 [[nodiscard]] auto operator->() const -> pointer;
531 auto operator++() -> const_iterator &;
532 auto operator++(int) -> const_iterator;
533 [[nodiscard]] auto operator==(const const_iterator &other) const -> bool;
534 [[nodiscard]] auto operator!=(const const_iterator &other) const -> bool;
535
536 private:
537#if defined(_MSC_VER)
538#pragma warning(push)
539#pragma warning(disable : 4251)
540#endif
541 std::string_view raw_{};
542 std::size_t pair_start_{std::string_view::npos};
543 value_type current_{};
544#if defined(_MSC_VER)
545#pragma warning(pop)
546#endif
547 };
548
550 [[nodiscard]] auto begin() const -> const_iterator;
551
553 [[nodiscard]] auto end() const -> const_iterator;
554
555 private:
556#if defined(_MSC_VER)
557#pragma warning(push)
558#pragma warning(disable : 4251)
559#endif
560 std::string_view raw_;
561#if defined(_MSC_VER)
562#pragma warning(pop)
563#endif
564 };
565
578 [[nodiscard]] auto query() const -> std::optional<Query>;
579
592 auto query(const std::string_view query) -> URI &;
593
604 [[nodiscard]] auto recompose() const -> std::string;
605
619 [[nodiscard]] auto recompose_relative() const -> std::string;
620
635 [[nodiscard]] auto recompose_without_fragment() const
636 -> std::optional<std::string>;
637
653 auto canonicalize() -> URI &;
654
665 [[nodiscard]] auto to_path() const -> std::filesystem::path;
666
679 auto resolve_from(const URI &base) -> URI &;
680
706 auto relative_to(const URI &base) -> URI &;
707
723 auto rebase(const URI &base, const URI &new_base) -> URI &;
724
740 auto rebase(const URI &base, URI &&new_base) -> URI &;
741
756 [[nodiscard]] auto has_same_authority(const URI &other) const noexcept
757 -> bool;
758
773 [[nodiscard]] auto userinfo() const -> std::optional<std::string_view>;
774
788 auto userinfo(const std::string_view userinfo) -> URI &;
789
792 auto operator==(const URI &other) const noexcept -> bool;
793
795 auto operator<(const URI &other) const noexcept -> bool;
796
808 static auto from_fragment(const std::string_view fragment) -> URI;
809
821 static auto from_unescaped_fragment(const std::string_view fragment) -> URI;
822
834 static auto from_path(const std::filesystem::path &path) -> URI;
835
848 static auto from_iri(std::string_view input) -> URI;
849
862 [[nodiscard]] auto is_internationalized() const noexcept -> bool;
863
875 static auto canonicalize(std::string_view input) -> std::string;
876
890 [[nodiscard]] static auto escape(std::string_view input,
891 bool maybe_encoded = false) -> std::string;
892
908 template <typename Output>
909 static auto escape(const std::string_view input, Output &output,
910 const bool maybe_encoded = false) -> void {
911 output.reserve(output.size() + (input.size() * 3));
912 for (std::size_t position = 0; position < input.size();) {
913 auto byte{static_cast<unsigned char>(input[position])};
914 std::size_t advance{1};
915 // Treat the input as possibly already encoded by decoding each valid
916 // escape before re-encoding, so a valid escape survives and a needlessly
917 // encoded unreserved octet is decoded
918 if (maybe_encoded && input[position] == '%' &&
919 position + 2 < input.size()) {
920 const auto high{hex_digit_value(input[position + 1])};
921 const auto low{high < 0 ? static_cast<std::int8_t>(-1)
922 : hex_digit_value(input[position + 2])};
923 if (low >= 0) {
924 byte = static_cast<unsigned char>((high << 4) | low);
925 advance = 3;
926 }
927 }
928
929 position += advance;
930 // RFC 3986 Section 2.3: the unreserved set passes through unescaped
931 if (is_alphanum(static_cast<char>(byte)) || byte == '-' || byte == '.' ||
932 byte == '_' || byte == '~') {
933 output.push_back(static_cast<char>(byte));
934 } else {
935 // RFC 3986 Section 2.1: percent-encode with uppercase hexadecimal
936 const auto high{static_cast<unsigned char>((byte >> 4U) & 0x0FU)};
937 const auto low{static_cast<unsigned char>(byte & 0x0FU)};
938 output.push_back('%');
939 output.push_back(
940 static_cast<char>(high < 10 ? '0' + high : 'A' + high - 10));
941 output.push_back(
942 static_cast<char>(low < 10 ? '0' + low : 'A' + low - 10));
943 }
944 }
945 }
946
968 template <typename Output>
969 static auto escape_reference(const std::string_view input, Output &output)
970 -> void {
971 // RFC 3986 Section 2.2 and Section 2.3: the unreserved characters, the
972 // sub-delims, and the gen-delims other than the square brackets and the
973 // number sign
974 static constexpr std::array<std::uint8_t, 256> PASS_THROUGH{{
975 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x00
976 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x10
977 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x20
978 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, // 0x30
979 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40
980 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, // 0x50
981 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60
982 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, // 0x70
983 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x80
984 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x90
985 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xA0
986 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xB0
987 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xC0
988 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xD0
989 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xE0
990 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // 0xF0
991 }};
992
993 bool in_fragment{false};
994 // The square brackets are rare, so the IP literal is only located once
995 // one of them shows up
996 bool literal_located{false};
997 std::pair<std::size_t, std::size_t> literal{std::string_view::npos,
998 std::string_view::npos};
999 std::size_t run_start{0};
1000 for (std::size_t position = 0; position < input.size(); position += 1) {
1001 const auto byte{static_cast<unsigned char>(input[position])};
1002 // RFC 3986 Section 2.1: pct-encoded = "%" HEXDIG HEXDIG
1003 if (PASS_THROUGH[byte] != 0 ||
1004 (byte == '%' && is_percent_triplet(input, position))) {
1005 continue;
1006 }
1007
1008 // RFC 3986 Section 3.5: "A fragment identifier component is indicated
1009 // by the presence of a number sign ("#") character and terminated by
1010 // the end of the URI", where fragment = *( pchar / "/" / "?" ) leaves no
1011 // room for another number sign
1012 if (byte == '#' && !in_fragment) {
1013 in_fragment = true;
1014 continue;
1015 }
1016
1017 if (byte == '[' || byte == ']') [[unlikely]] {
1018 if (!literal_located) {
1019 literal = ip_literal_brackets(input);
1020 literal_located = true;
1021 }
1022
1023 if (position == literal.first || position == literal.second) {
1024 continue;
1025 }
1026 }
1027
1028 // The characters that pass through are appended in runs
1029 output.append(input.substr(run_start, position - run_start));
1030 // RFC 3986 Section 2.1: percent-encode with uppercase hexadecimal
1031 const auto high{static_cast<unsigned char>((byte >> 4U) & 0x0FU)};
1032 const auto low{static_cast<unsigned char>(byte & 0x0FU)};
1033 const std::array<char, 3> encoded{
1034 {'%', static_cast<char>(high < 10 ? '0' + high : 'A' + high - 10),
1035 static_cast<char>(low < 10 ? '0' + low : 'A' + low - 10)}};
1036 output.append(std::string_view{encoded.data(), encoded.size()});
1037 run_start = position + 1;
1038 }
1039
1040 output.append(input.substr(run_start));
1041 }
1042
1063 template <typename Output>
1064 static auto append_query_parameter(Output &sink, const std::string_view name,
1065 const std::string_view value,
1066 const char opener = '?') -> void {
1067 if (!sink.empty() && sink.back() != opener && sink.back() != '&') {
1068 sink.push_back('&');
1069 }
1070
1071 URI::escape(name, sink);
1072 sink.push_back('=');
1073 URI::escape(value, sink);
1074 }
1075
1086 [[nodiscard]] static auto unescape(std::string_view input) -> std::string;
1087
1106 template <typename Output>
1107 [[nodiscard]] static auto unescape_form(const std::string_view input,
1108 Output &output) -> bool {
1109 const auto base{output.size()};
1110 output.reserve(base + input.size());
1111 for (std::size_t position = 0; position < input.size();) {
1112 const auto character{input[position]};
1113 if (character == '+') {
1114 output.push_back(' ');
1115 position += 1;
1116 } else if (character == '%') {
1117 const auto high{position + 2 < input.size()
1118 ? hex_digit_value(input[position + 1])
1119 : static_cast<std::int8_t>(-1)};
1120 const auto low{high < 0 ? static_cast<std::int8_t>(-1)
1121 : hex_digit_value(input[position + 2])};
1122 if (low < 0) {
1123 output.resize(base, '\0');
1124 return false;
1125 }
1126
1127 output.push_back(static_cast<char>((high << 4) | low));
1128 position += 3;
1129 } else {
1130 output.push_back(character);
1131 position += 1;
1132 }
1133 }
1134
1135 return true;
1136 }
1137
1154 template <typename Output>
1155 static auto escape_form(const std::string_view input, Output &output)
1156 -> void {
1157 output.reserve(output.size() + (input.size() * 3));
1158 for (const auto character : input) {
1159 const auto byte{static_cast<unsigned char>(character)};
1160 // WHATWG URL Section 5.2 percent-encodes with the space as plus flag set
1161 if (byte == ' ') {
1162 output.push_back('+');
1163 continue;
1164 }
1165
1166 // WHATWG URL Section 1.3: "The application/x-www-form-urlencoded
1167 // percent-encode set contains all code points, except the ASCII
1168 // alphanumeric, U+002A (*), U+002D (-), U+002E (.), and U+005F (_)"
1169 if (is_alphanum(character) || byte == '*' || byte == '-' || byte == '.' ||
1170 byte == '_') {
1171 output.push_back(character);
1172 continue;
1173 }
1174
1175 // RFC 3986 Section 2.1: percent-encode with uppercase hexadecimal
1176 const auto high{static_cast<unsigned char>((byte >> 4U) & 0x0FU)};
1177 const auto low{static_cast<unsigned char>(byte & 0x0FU)};
1178 output.push_back('%');
1179 output.push_back(
1180 static_cast<char>(high < 10 ? '0' + high : 'A' + high - 10));
1181 output.push_back(
1182 static_cast<char>(low < 10 ? '0' + low : 'A' + low - 10));
1183 }
1184 }
1185
1203 template <typename Output>
1204 static auto append_form_parameter(Output &sink, const std::string_view name,
1205 const std::string_view value) -> void {
1206 // WHATWG URL Section 5.2: "If output is not the empty string, then append
1207 // U+0026 (&) to output", which a caller that wrote the separator itself
1208 // has already done
1209 if (!sink.empty() && sink.back() != '&') {
1210 sink.push_back('&');
1211 }
1212
1213 URI::escape_form(name, sink);
1214 sink.push_back('=');
1215 URI::escape_form(value, sink);
1216 }
1217
1239 template <typename Container>
1240 requires requires(Container container, Container::value_type entry) {
1241 container.emplace_back();
1242 entry.first.push_back('\0');
1243 entry.second.push_back('\0');
1244 }
1245 static auto parse_form(const std::string_view input, Container &output)
1246 -> void {
1247 std::size_t position{0};
1248 while (position <= input.size()) {
1249 const auto separator{input.find('&', position)};
1250 const auto end{separator == std::string_view::npos ? input.size()
1251 : separator};
1252 const auto sequence{input.substr(position, end - position)};
1253 position = end + 1;
1254
1255 // WHATWG URL Section 5.1: "If bytes is the empty byte sequence, then
1256 // continue"
1257 if (sequence.empty()) {
1258 continue;
1259 }
1260
1261 // WHATWG URL Section 5.1: "If bytes contains a 0x3D (=), then let name
1262 // be the bytes from the start of bytes up to but excluding its first
1263 // 0x3D (=), and let value be the bytes, if any, after the first 0x3D
1264 // (=) up to the end of bytes"
1265 const auto equals{sequence.find('=')};
1266 auto &entry{output.emplace_back()};
1267 if (equals == std::string_view::npos) {
1268 URI::decode_form_component(sequence, entry.first);
1269 } else {
1270 URI::decode_form_component(sequence.substr(0, equals), entry.first);
1271 URI::decode_form_component(sequence.substr(equals + 1), entry.second);
1272 }
1273 }
1274 }
1275
1286 [[nodiscard]] static auto normalize_path(std::string_view path)
1287 -> std::string;
1288
1300 [[nodiscard]] static auto is_scheme(std::string_view input) noexcept -> bool;
1301
1312 [[nodiscard]] static auto is_gen_delim(char character) noexcept -> bool;
1313
1327 [[nodiscard]] static auto is_pchar(char character) noexcept -> bool;
1328
1340 [[nodiscard]] static auto is_uri(std::string_view input) noexcept -> bool;
1341
1354 [[nodiscard]] static auto is_uri_reference(std::string_view input) noexcept
1355 -> bool;
1356
1384 [[nodiscard]] static auto
1385 is_absolute_path_reference(std::string_view input) noexcept -> bool;
1386
1397 [[nodiscard]] static auto is_iri(std::string_view input) noexcept -> bool;
1398
1411 [[nodiscard]] static auto is_iri_reference(std::string_view input) noexcept
1412 -> bool;
1413
1425 [[nodiscard]] static auto strip_path_prefix(std::string_view path,
1426 std::string_view prefix)
1427 -> std::optional<std::string>;
1428
1440 [[nodiscard]] static auto rebase_path(std::string_view path,
1441 std::string_view old_prefix,
1442 std::string_view new_prefix)
1443 -> std::optional<std::string>;
1444
1445private:
1446 auto parse(std::string_view input) -> void;
1447
1448 // The positions of the square brackets around the IP literal host of a URI
1449 // reference, if it has one
1450 [[nodiscard]] static auto ip_literal_brackets(std::string_view input) noexcept
1451 -> std::pair<std::size_t, std::size_t>;
1452
1453 // WHATWG URL Section 5.1: "Replace any 0x2B (+) in name and value with 0x20
1454 // (SP)" and then percent-decode, which Section 1.3 defines to append a "%"
1455 // that is not followed by two hexadecimal digits as it appears rather than
1456 // to fail
1457 template <typename Output>
1458 static auto decode_form_component(const std::string_view input,
1459 Output &output) -> void {
1460 output.reserve(output.size() + input.size());
1461 for (std::size_t position = 0; position < input.size();) {
1462 const auto character{input[position]};
1463 if (character == '+') {
1464 output.push_back(' ');
1465 position += 1;
1466 continue;
1467 }
1468
1469 if (character == '%' && position + 2 < input.size()) {
1470 const auto high{hex_digit_value(input[position + 1])};
1471 const auto low{high < 0 ? static_cast<std::int8_t>(-1)
1472 : hex_digit_value(input[position + 2])};
1473 if (low >= 0) {
1474 output.push_back(static_cast<char>((high << 4) | low));
1475 position += 3;
1476 continue;
1477 }
1478 }
1479
1480 output.push_back(character);
1481 position += 1;
1482 }
1483 }
1484
1485// Exporting symbols that depends on the standard C++ library is considered
1486// safe.
1487// https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-2-c4275?view=msvc-170&redirectedfrom=MSDN
1488#if defined(_MSC_VER)
1489#pragma warning(push)
1490#pragma warning(disable : 4251)
1491#endif
1492 std::optional<std::string> path_{};
1493 std::optional<std::string> userinfo_{};
1494 std::optional<std::string> host_{};
1495 std::optional<std::uint32_t> port_{};
1496 std::optional<std::string> scheme_{};
1497 std::optional<std::string> fragment_{};
1498 std::optional<std::string> query_{};
1499 bool ip_literal_{false};
1500 // Whether this object was parsed as an IRI (RFC 3987) rather than a URI
1501 // (RFC 3986)
1502 bool iri_{false};
1503#if defined(_MSC_VER)
1504#pragma warning(pop)
1505#endif
1506};
1507
1508} // namespace sourcemeta::core
1509
1510#endif
Definition uri.h:468
auto at(const std::string_view name) const -> std::optional< std::string_view >
auto raw() const -> std::string_view
Query(const std::string_view raw)
constexpr auto is_alphanum(const Character character) noexcept -> bool
Definition text.h:293
auto hex_digit_value(const char character) noexcept -> std::int8_t
Definition text.h:855
auto is_percent_triplet(const std::string_view input, const std::size_t position) noexcept -> bool
Definition text.h:906
static auto unescape_form(const std::string_view input, Output &output) -> bool
Definition uri.h:1107
static auto is_scheme(std::string_view input) noexcept -> bool
auto is_http() const -> bool
auto is_ipv4() const -> bool
auto append_path(std::string_view path) -> URI &
auto relative_to(const URI &base) -> URI &
auto to_path() const -> std::filesystem::path
auto is_urn() const -> bool
auto is_relative() const -> bool
auto scheme() const -> std::optional< std::string_view >
static auto escape_reference(const std::string_view input, Output &output) -> void
Definition uri.h:969
static auto from_path(const std::filesystem::path &path) -> URI
auto recompose_without_fragment() const -> std::optional< std::string >
auto is_mailto() const -> bool
auto is_ipv6() const -> bool
auto path() const -> std::optional< std::string_view >
auto is_https() const -> bool
static auto from_unescaped_fragment(const std::string_view fragment) -> URI
URI(URI &&) noexcept=default
Move constructor.
auto resolve_from(const URI &base) -> URI &
auto recompose() const -> std::string
static auto is_iri(std::string_view input) noexcept -> bool
static auto is_pchar(char character) noexcept -> bool
URI(std::istream &input)
static auto is_absolute_path_reference(std::string_view input) noexcept -> bool
static auto parse_form(const std::string_view input, Container &output) -> void
Definition uri.h:1245
static auto is_iri_reference(std::string_view input) noexcept -> bool
URI(const URI &)=default
Copy constructor.
URI()=default
Default constructor creates an empty URI.
auto is_localhost() const -> bool
auto fragment() const -> std::optional< std::string_view >
static auto unescape(std::string_view input) -> std::string
auto unescaped_fragment(const std::string_view fragment) -> URI &
static auto append_form_parameter(Output &sink, const std::string_view name, const std::string_view value) -> void
Definition uri.h:1204
auto has_same_authority(const URI &other) const noexcept -> bool
auto is_fragment_only() const -> bool
auto canonicalize() -> URI &
auto is_internationalized() const noexcept -> bool
static auto normalize_path(std::string_view path) -> std::string
static auto append_query_parameter(Output &sink, const std::string_view name, const std::string_view value, const char opener='?') -> void
Definition uri.h:1064
auto host() const -> std::optional< std::string_view >
auto is_absolute() const noexcept -> bool
auto userinfo() const -> std::optional< std::string_view >
auto is_file() const -> bool
static auto escape_form(const std::string_view input, Output &output) -> void
Definition uri.h:1155
auto empty() const -> bool
static auto is_uri_reference(std::string_view input) noexcept -> bool
auto is_loopback() const -> bool
auto is_tag() const -> bool
auto rebase(const URI &base, const URI &new_base) -> URI &
static auto escape(std::string_view input, bool maybe_encoded=false) -> std::string
auto authority() const -> std::optional< std::string >
static auto is_gen_delim(char character) noexcept -> bool
auto recompose_relative() const -> std::string
auto port() const -> std::optional< std::uint32_t >
static auto from_iri(std::string_view input) -> URI
static auto strip_path_prefix(std::string_view path, std::string_view prefix) -> std::optional< std::string >
auto extension(std::string &&extension) -> URI &
static auto rebase_path(std::string_view path, std::string_view old_prefix, std::string_view new_prefix) -> std::optional< std::string >
auto query() const -> std::optional< Query >
static auto from_fragment(const std::string_view fragment) -> URI
static auto is_uri(std::string_view input) noexcept -> bool