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

Method parse_path

src/url.cpp:514–548  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

512}
513
514ada_really_inline void url::parse_path(std::string_view input) {
515 ada_log("parse_path ", input);
516 std::string tmp_buffer;
517 std::string_view internal_input;
518 if (unicode::has_tabs_or_newline(input)) {
519 tmp_buffer = input;
520 // Optimization opportunity: Instead of copying and then pruning, we could
521 // just directly build the string from user_input.
522 helpers::remove_ascii_tab_or_newline(tmp_buffer);
523 internal_input = tmp_buffer;
524 } else {
525 internal_input = input;
526 }
527
528 // If url is special, then:
529 if (is_special()) {
530 if (internal_input.empty()) {
531 path = "/";
532 } else if ((internal_input[0] == '/') || (internal_input[0] == '\\')) {
533 helpers::parse_prepared_path(internal_input.substr(1), type, path);
534 } else {
535 helpers::parse_prepared_path(internal_input, type, path);
536 }
537 } else if (!internal_input.empty()) {
538 if (internal_input[0] == '/') {
539 helpers::parse_prepared_path(internal_input.substr(1), type, path);
540 } else {
541 helpers::parse_prepared_path(internal_input, type, path);
542 }
543 } else {
544 if (!host.has_value()) {
545 path = "/";
546 }
547 }
548}
549
550[[nodiscard]] std::string url::to_string() const {
551 if (!is_valid) {

Callers

nothing calls this directly

Calls 5

has_tabs_or_newlineFunction · 0.85
is_specialFunction · 0.85
parse_prepared_pathFunction · 0.85
has_valueMethod · 0.45

Tested by

no test coverage detected