1#if ADA_INCLUDE_URL_PATTERN
11tl::expected<url_pattern_init, errors> url_pattern_init::process(
13 std::optional<std::string_view>
protocol,
14 std::optional<std::string_view> username,
15 std::optional<std::string_view> password,
16 std::optional<std::string_view>
hostname,
17 std::optional<std::string_view> port,
18 std::optional<std::string_view>
pathname,
19 std::optional<std::string_view>
search,
20 std::optional<std::string_view> hash) {
28 if (username.has_value())
result.username = *username;
31 if (password.has_value())
result.password = *password;
37 if (port.has_value())
result.port = *port;
46 if (hash.has_value())
result.hash = *hash;
49 std::optional<url_aggregator>
base_url{};
52 if (
init.base_url.has_value()) {
63 if (!
init.protocol.has_value()) {
74 if (type != process_type::pattern && !
init.protocol && !
init.hostname &&
76 result.username = url_pattern_helpers::process_base_url_string(
85 if (type != process_type::pattern && !
init.protocol && !
init.hostname &&
87 result.password = url_pattern_helpers::process_base_url_string(
92 if (!
init.protocol && !
init.hostname) {
99 url_pattern_helpers::process_base_url_string(
base_host, type);
113 result.pathname = url_pattern_helpers::process_base_url_string(
124 result.search = url_pattern_helpers::process_base_url_string(
135 result.hash = url_pattern_helpers::process_base_url_string(
152 if (
init.username.has_value()) {
162 if (
init.password.has_value()) {
172 if (
init.hostname.has_value()) {
192 if (
init.pathname.has_value()) {
202 !url_pattern_helpers::is_absolute_pathname(*
result.pathname, type)) {
207 std::string
base_url_path = url_pattern_helpers::process_base_url_string(
261tl::expected<std::string, errors> url_pattern_init::process_protocol(
263 ada_log(
"process_protocol=", value,
" [", type,
"]");
266 if (value.ends_with(
":")) {
267 value.remove_suffix(1);
270 if (type == process_type::pattern) {
271 return std::string(value);
274 return url_pattern_helpers::canonicalize_protocol(value);
277tl::expected<std::string, errors> url_pattern_init::process_username(
280 if (type == process_type::pattern) {
281 return std::string(value);
284 return url_pattern_helpers::canonicalize_username(value);
287tl::expected<std::string, errors> url_pattern_init::process_password(
290 if (type == process_type::pattern) {
291 return std::string(value);
294 return url_pattern_helpers::canonicalize_password(value);
297tl::expected<std::string, errors> url_pattern_init::process_hostname(
299 ada_log(
"process_hostname value=", value,
" type=", type);
301 if (type == process_type::pattern) {
302 return std::string(value);
305 return url_pattern_helpers::canonicalize_hostname(value);
308tl::expected<std::string, errors> url_pattern_init::process_port(
311 if (type == process_type::pattern) {
312 return std::string(port);
316 return url_pattern_helpers::canonicalize_port_with_protocol(port,
protocol);
319tl::expected<std::string, errors> url_pattern_init::process_pathname(
322 if (type == process_type::pattern) {
323 return std::string(value);
329 return url_pattern_helpers::canonicalize_pathname(value);
334 return url_pattern_helpers::canonicalize_opaque_pathname(value);
337tl::expected<std::string, errors> url_pattern_init::process_search(
341 if (value.starts_with(
"?")) {
342 value.remove_prefix(1);
350 if (type == process_type::pattern) {
351 return std::string(value);
354 return url_pattern_helpers::canonicalize_search(value);
357tl::expected<std::string, errors> url_pattern_init::process_hash(
361 if (value.starts_with(
"#")) {
362 value.remove_prefix(1);
366 if (type == process_type::pattern) {
367 return std::string(value);
370 return url_pattern_helpers::canonicalize_hash(value);
#define ADA_ASSERT_TRUE(COND)
tl::expected< result_type, ada::errors > result
template ada::result< url_aggregator > parse< url_aggregator >(std::string_view input, const url_aggregator *base_url)
ada_warn_unused ada::result< result_type > parse(std::string_view input, const result_type *base_url=nullptr)
Declaration for the URLPattern inline functions.