MCPcopy Create free account
hub / github.com/ada-url/ada / set_protocol

Method set_protocol

src/url.cpp:905–927  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

903}
904
905bool url::set_protocol(const std::string_view input) {
906 std::string view(input);
907 helpers::remove_ascii_tab_or_newline(view);
908 if (view.empty()) {
909 return true;
910 }
911
912 // Schemes should start with alpha values.
913 if (!checkers::is_alpha(view[0])) {
914 return false;
915 }
916
917 view.append(":");
918
919 std::string::iterator pointer =
920 std::ranges::find_if_not(view, unicode::is_alnum_plus);
921
922 if (pointer != view.end() && *pointer == ':') {
923 return parse_scheme<true>(
924 std::string_view(view.data(), pointer - view.begin()));
925 }
926 return false;
927}
928
929bool url::set_href(const std::string_view input) {
930 ada::result<ada::url> out = ada::parse<ada::url>(input);

Callers 5

mainFunction · 0.45
ada_set_protocolFunction · 0.45
TYPED_TESTFunction · 0.45
TYPED_TESTFunction · 0.45
LLVMFuzzerTestOneInputFunction · 0.45

Calls 5

is_alphaFunction · 0.85
appendMethod · 0.80
endMethod · 0.80
beginMethod · 0.80

Tested by 2

TYPED_TESTFunction · 0.36
TYPED_TESTFunction · 0.36