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

Method match

test-app/runtime/src/main/cpp/ada/ada.h:9148–9410  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9146
9147template <url_pattern_regex::regex_concept regex_provider>
9148result<std::optional<url_pattern_result>> url_pattern<regex_provider>::match(
9149 const url_pattern_input& input, const std::string_view* base_url_string) {
9150 std::string protocol{};
9151 std::string username{};
9152 std::string password{};
9153 std::string hostname{};
9154 std::string port{};
9155 std::string pathname{};
9156 std::string search{};
9157 std::string hash{};
9158
9159 // Let inputs be an empty list.
9160 // Append input to inputs.
9161 std::vector inputs{input};
9162
9163 // If input is a URLPatternInit then:
9164 if (std::holds_alternative<url_pattern_init>(input)) {
9165 ada_log(
9166 "url_pattern::match called with url_pattern_init and base_url_string=",
9167 base_url_string);
9168 // If baseURLString was given, throw a TypeError.
9169 if (base_url_string) {
9170 ada_log("failed to match because base_url_string was given");
9171 return tl::unexpected(errors::type_error);
9172 }
9173
9174 // Let applyResult be the result of process a URLPatternInit given input,
9175 // "url", protocol, username, password, hostname, port, pathname, search,
9176 // and hash.
9177 auto apply_result = url_pattern_init::process(
9178 std::get<url_pattern_init>(input), url_pattern_init::process_type::url,
9179 protocol, username, password, hostname, port, pathname, search, hash);
9180
9181 // If this throws an exception, catch it, and return null.
9182 if (!apply_result.has_value()) {
9183 ada_log("match returned std::nullopt because process threw");
9184 return std::nullopt;
9185 }
9186
9187 // Set protocol to applyResult["protocol"].
9188 ADA_ASSERT_TRUE(apply_result->protocol.has_value());
9189 protocol = std::move(apply_result->protocol.value());
9190
9191 // Set username to applyResult["username"].
9192 ADA_ASSERT_TRUE(apply_result->username.has_value());
9193 username = std::move(apply_result->username.value());
9194
9195 // Set password to applyResult["password"].
9196 ADA_ASSERT_TRUE(apply_result->password.has_value());
9197 password = std::move(apply_result->password.value());
9198
9199 // Set hostname to applyResult["hostname"].
9200 ADA_ASSERT_TRUE(apply_result->hostname.has_value());
9201 hostname = std::move(apply_result->hostname.value());
9202
9203 // Set port to applyResult["port"].
9204 ADA_ASSERT_TRUE(apply_result->port.has_value());
9205 port = std::move(apply_result->port.value());

Callers 8

parseLogcatTimestampFunction · 0.45
checkTestResultsFunction · 0.45
fnNameForFunction · 0.45
InvalidateMethod · 0.45
TemplateHashMapImplMethod · 0.45
ProbeMethod · 0.45

Calls 15

unexpectedClass · 0.85
valueMethod · 0.80
emplace_backMethod · 0.80
get_pathnameMethod · 0.80
has_searchMethod · 0.80
has_hashMethod · 0.80
get_protocolMethod · 0.60
get_usernameMethod · 0.60
get_passwordMethod · 0.60
get_hostnameMethod · 0.60
get_portMethod · 0.60

Tested by

no test coverage detected