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

Function canonicalize_hostname

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

Source from the content-addressed store, hash-verified

16130}
16131
16132tl::expected<std::string, errors> canonicalize_hostname(
16133 std::string_view input) {
16134 ada_log("canonicalize_hostname input=", input);
16135 // If value is the empty string, return value.
16136 if (input.empty()) [[unlikely]] {
16137 return "";
16138 }
16139 // Let dummyURL be a new URL record.
16140 // Let parseResult be the result of running the basic URL parser given value
16141 // with dummyURL as url and hostname state as state override.
16142
16143 // IMPORTANT: The protocol needs to be a special protocol, otherwise the
16144 // hostname will not be converted using IDNA.
16145 auto url = ada::parse<url_aggregator>("https://dummy.test", nullptr);
16146 ADA_ASSERT_TRUE(url);
16147 // if (!isValidHostnameInput(hostname)) return kj::none;
16148 if (!url->set_hostname(input)) {
16149 // If parseResult is failure, then throw a TypeError.
16150 return tl::unexpected(errors::type_error);
16151 }
16152 // Return dummyURL's host, serialized, or empty string if it is null.
16153 return std::string(url->get_hostname());
16154}
16155
16156tl::expected<std::string, errors> canonicalize_ipv6_hostname(
16157 std::string_view input) {

Callers 1

process_hostnameMethod · 0.85

Calls 4

unexpectedClass · 0.85
set_hostnameMethod · 0.80
get_hostnameMethod · 0.60
emptyMethod · 0.45

Tested by

no test coverage detected