| 512 | } |
| 513 | |
| 514 | ada_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) { |
nothing calls this directly
no test coverage detected