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

Function canonicalize_port

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

Source from the content-addressed store, hash-verified

16171}
16172
16173tl::expected<std::string, errors> canonicalize_port(
16174 std::string_view port_value) {
16175 // If portValue is the empty string, return portValue.
16176 if (port_value.empty()) [[unlikely]] {
16177 return "";
16178 }
16179 // Let dummyURL be a new URL record.
16180 // If protocolValue was given, then set dummyURL's scheme to protocolValue.
16181 // Let parseResult be the result of running basic URL parser given portValue
16182 // with dummyURL as url and port state as state override.
16183 auto url = ada::parse<url_aggregator>("fake://dummy.test", nullptr);
16184 ADA_ASSERT_TRUE(url);
16185 if (url->set_port(port_value)) {
16186 // Return dummyURL's port, serialized, or empty string if it is null.
16187 return std::string(url->get_port());
16188 }
16189 // If parseResult is failure, then throw a TypeError.
16190 return tl::unexpected(errors::type_error);
16191}
16192
16193tl::expected<std::string, errors> canonicalize_port_with_protocol(
16194 std::string_view port_value, std::string_view protocol) {

Callers

nothing calls this directly

Calls 4

unexpectedClass · 0.85
set_portMethod · 0.80
get_portMethod · 0.60
emptyMethod · 0.45

Tested by

no test coverage detected