| 7674 | } |
| 7675 | |
| 7676 | inline void url_aggregator::append_base_username(const std::string_view input) { |
| 7677 | ada_log("url_aggregator::append_base_username ", input); |
| 7678 | ADA_ASSERT_TRUE(validate()); |
| 7679 | ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer)); |
| 7680 | #if ADA_DEVELOPMENT_CHECKS |
| 7681 | // computing the expected password. |
| 7682 | std::string username_expected(get_username()); |
| 7683 | username_expected.append(input); |
| 7684 | #endif // ADA_DEVELOPMENT_CHECKS |
| 7685 | add_authority_slashes_if_needed(); |
| 7686 | |
| 7687 | // If input is empty, do nothing. |
| 7688 | if (input.empty()) { |
| 7689 | return; |
| 7690 | } |
| 7691 | |
| 7692 | uint32_t difference = uint32_t(input.size()); |
| 7693 | buffer.insert(components.username_end, input); |
| 7694 | components.username_end += difference; |
| 7695 | components.host_start += difference; |
| 7696 | |
| 7697 | if (buffer[components.host_start] != '@' && |
| 7698 | components.host_start != components.host_end) { |
| 7699 | buffer.insert(components.host_start, "@"); |
| 7700 | difference++; |
| 7701 | } |
| 7702 | |
| 7703 | components.host_end += difference; |
| 7704 | components.pathname_start += difference; |
| 7705 | if (components.search_start != url_components::omitted) { |
| 7706 | components.search_start += difference; |
| 7707 | } |
| 7708 | if (components.hash_start != url_components::omitted) { |
| 7709 | components.hash_start += difference; |
| 7710 | } |
| 7711 | #if ADA_DEVELOPMENT_CHECKS |
| 7712 | std::string username_after(get_username()); |
| 7713 | ADA_ASSERT_EQUAL( |
| 7714 | username_expected, username_after, |
| 7715 | "append_base_username problem after inserting " + std::string(input)); |
| 7716 | #endif // ADA_DEVELOPMENT_CHECKS |
| 7717 | ADA_ASSERT_TRUE(validate()); |
| 7718 | } |
| 7719 | |
| 7720 | constexpr void url_aggregator::clear_password() { |
| 7721 | ada_log("url_aggregator::clear_password ", to_string()); |