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

Function canonicalize_protocol

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

Source from the content-addressed store, hash-verified

16067}
16068
16069tl::expected<std::string, errors> canonicalize_protocol(
16070 std::string_view input) {
16071 ada_log("canonicalize_protocol called with input=", input);
16072 // If value is the empty string, return value.
16073 if (input.empty()) [[unlikely]] {
16074 return "";
16075 }
16076
16077 // IMPORTANT: Deviation from the spec. We remove the trailing ':' here.
16078 if (input.ends_with(":")) {
16079 input.remove_suffix(1);
16080 }
16081
16082 // Let dummyURL be a new URL record.
16083 // Let parseResult be the result of running the basic URL parser given value
16084 // followed by "://dummy.test", with dummyURL as url.
16085 if (auto dummy_url = ada::parse<url_aggregator>(
16086 std::string(input) + "://dummy.test", nullptr)) {
16087 // IMPORTANT: Deviation from the spec. We remove the trailing ':' here.
16088 // Since URL parser always return protocols ending with `:`
16089 auto protocol = dummy_url->get_protocol();
16090 protocol.remove_suffix(1);
16091 return std::string(protocol);
16092 }
16093 // If parseResult is failure, then throw a TypeError.
16094 return tl::unexpected(errors::type_error);
16095}
16096
16097tl::expected<std::string, errors> canonicalize_username(
16098 std::string_view input) {

Callers 1

process_protocolMethod · 0.85

Calls 3

unexpectedClass · 0.85
get_protocolMethod · 0.60
emptyMethod · 0.45

Tested by

no test coverage detected