MCPcopy Create free account
hub / github.com/NativeScript/android / process

Method process

test-app/runtime/src/main/cpp/ada/ada.cpp:15511–15759  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15509namespace ada {
15510
15511tl::expected<url_pattern_init, errors> url_pattern_init::process(
15512 const url_pattern_init& init, url_pattern_init::process_type type,
15513 std::optional<std::string_view> protocol,
15514 std::optional<std::string_view> username,
15515 std::optional<std::string_view> password,
15516 std::optional<std::string_view> hostname,
15517 std::optional<std::string_view> port,
15518 std::optional<std::string_view> pathname,
15519 std::optional<std::string_view> search,
15520 std::optional<std::string_view> hash) {
15521 // Let result be the result of creating a new URLPatternInit.
15522 auto result = url_pattern_init{};
15523
15524 // If protocol is not null, set result["protocol"] to protocol.
15525 if (protocol.has_value()) result.protocol = *protocol;
15526
15527 // If username is not null, set result["username"] to username.
15528 if (username.has_value()) result.username = *username;
15529
15530 // If password is not null, set result["password"] to password.
15531 if (password.has_value()) result.password = *password;
15532
15533 // If hostname is not null, set result["hostname"] to hostname.
15534 if (hostname.has_value()) result.hostname = *hostname;
15535
15536 // If port is not null, set result["port"] to port.
15537 if (port.has_value()) result.port = *port;
15538
15539 // If pathname is not null, set result["pathname"] to pathname.
15540 if (pathname.has_value()) result.pathname = *pathname;
15541
15542 // If search is not null, set result["search"] to search.
15543 if (search.has_value()) result.search = *search;
15544
15545 // If hash is not null, set result["hash"] to hash.
15546 if (hash.has_value()) result.hash = *hash;
15547
15548 // Let baseURL be null.
15549 std::optional<url_aggregator> base_url{};
15550
15551 // If init["baseURL"] exists:
15552 if (init.base_url.has_value()) {
15553 // Set baseURL to the result of parsing init["baseURL"].
15554 auto parsing_result = ada::parse<url_aggregator>(*init.base_url);
15555 // If baseURL is failure, then throw a TypeError.
15556 if (!parsing_result) {
15557 return tl::unexpected(errors::type_error);
15558 }
15559 base_url = std::move(*parsing_result);
15560
15561 // If init["protocol"] does not exist, then set result["protocol"] to the
15562 // result of processing a base URL string given baseURL's scheme and type.
15563 if (!init.protocol.has_value()) {
15564 ADA_ASSERT_TRUE(base_url.has_value());
15565 std::string_view base_url_protocol = base_url->get_protocol();
15566 if (base_url_protocol.ends_with(":")) base_url_protocol.remove_suffix(1);
15567 result.protocol =
15568 url_pattern_helpers::process_base_url_string(base_url_protocol, type);

Callers

nothing calls this directly

Calls 13

unexpectedClass · 0.85
process_base_url_stringFunction · 0.85
is_absolute_pathnameFunction · 0.85
get_pathnameMethod · 0.80
appendMethod · 0.65
get_protocolMethod · 0.60
get_usernameMethod · 0.60
get_passwordMethod · 0.60
get_hostnameMethod · 0.60
get_portMethod · 0.60
get_searchMethod · 0.60
get_hashMethod · 0.60

Tested by

no test coverage detected