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

Function href_from_file

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

Source from the content-addressed store, hash-verified

11065 std::string_view input, const url_aggregator* base_url = nullptr);
11066
11067std::string href_from_file(std::string_view input) {
11068 // This is going to be much faster than constructing a URL.
11069 std::string tmp_buffer;
11070 std::string_view internal_input;
11071 if (unicode::has_tabs_or_newline(input)) {
11072 tmp_buffer = input;
11073 helpers::remove_ascii_tab_or_newline(tmp_buffer);
11074 internal_input = tmp_buffer;
11075 } else {
11076 internal_input = input;
11077 }
11078 std::string path;
11079 if (internal_input.empty()) {
11080 path = "/";
11081 } else if ((internal_input[0] == '/') || (internal_input[0] == '\\')) {
11082 helpers::parse_prepared_path(internal_input.substr(1),
11083 ada::scheme::type::FILE, path);
11084 } else {
11085 helpers::parse_prepared_path(internal_input, ada::scheme::type::FILE, path);
11086 }
11087 return "file://" + path;
11088}
11089
11090bool can_parse(std::string_view input, const std::string_view* base_input) {
11091 ada::url_aggregator base_aggregator;

Callers

nothing calls this directly

Calls 4

has_tabs_or_newlineFunction · 0.85
parse_prepared_pathFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected