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

Function canonicalize_hash

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

Source from the content-addressed store, hash-verified

16295}
16296
16297tl::expected<std::string, errors> canonicalize_hash(std::string_view input) {
16298 // If value is the empty string, return value.
16299 if (input.empty()) [[unlikely]] {
16300 return "";
16301 }
16302 // Let dummyURL be a new URL record.
16303 // Set dummyURL's fragment to the empty string.
16304 // Let parseResult be the result of running basic URL parser given value with
16305 // dummyURL as url and fragment state as state override.
16306 auto url = ada::parse<url_aggregator>("fake://dummy.test", nullptr);
16307 ADA_ASSERT_TRUE(url.has_value());
16308 url->set_hash(input);
16309 // Return dummyURL's fragment.
16310 if (url->has_hash()) {
16311 const auto hash = url->get_hash();
16312 if (!hash.empty()) {
16313 return std::string(hash.substr(1));
16314 }
16315 return "";
16316 }
16317 return tl::unexpected(errors::type_error);
16318}
16319
16320tl::expected<std::vector<token>, errors> tokenize(std::string_view input,
16321 token_policy policy) {

Callers 1

process_hashMethod · 0.85

Calls 6

unexpectedClass · 0.85
set_hashMethod · 0.80
has_hashMethod · 0.80
get_hashMethod · 0.60
emptyMethod · 0.45
has_valueMethod · 0.45

Tested by

no test coverage detected