| 7792 | } |
| 7793 | |
| 7794 | inline void url_aggregator::append_base_password(const std::string_view input) { |
| 7795 | ada_log("url_aggregator::append_base_password ", input, " ", to_string(), |
| 7796 | "\n", to_diagram()); |
| 7797 | ADA_ASSERT_TRUE(validate()); |
| 7798 | ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer)); |
| 7799 | #if ADA_DEVELOPMENT_CHECKS |
| 7800 | // computing the expected password. |
| 7801 | std::string password_expected = std::string(get_password()); |
| 7802 | password_expected.append(input); |
| 7803 | #endif // ADA_DEVELOPMENT_CHECKS |
| 7804 | add_authority_slashes_if_needed(); |
| 7805 | |
| 7806 | // If input is empty, do nothing. |
| 7807 | if (input.empty()) { |
| 7808 | return; |
| 7809 | } |
| 7810 | |
| 7811 | uint32_t difference = uint32_t(input.size()); |
| 7812 | if (has_password()) { |
| 7813 | buffer.insert(components.host_start, input); |
| 7814 | } else { |
| 7815 | difference++; // Increment for ":" |
| 7816 | buffer.insert(components.username_end, ":"); |
| 7817 | buffer.insert(components.username_end + 1, input); |
| 7818 | } |
| 7819 | components.host_start += difference; |
| 7820 | |
| 7821 | // The following line is required to add "@" to hostname. When updating |
| 7822 | // password if hostname does not start with "@", it is "append_base_password"s |
| 7823 | // responsibility to set it. |
| 7824 | if (buffer[components.host_start] != '@') { |
| 7825 | buffer.insert(components.host_start, "@"); |
| 7826 | difference++; |
| 7827 | } |
| 7828 | |
| 7829 | components.host_end += difference; |
| 7830 | components.pathname_start += difference; |
| 7831 | if (components.search_start != url_components::omitted) { |
| 7832 | components.search_start += difference; |
| 7833 | } |
| 7834 | if (components.hash_start != url_components::omitted) { |
| 7835 | components.hash_start += difference; |
| 7836 | } |
| 7837 | #if ADA_DEVELOPMENT_CHECKS |
| 7838 | std::string password_after(get_password()); |
| 7839 | ADA_ASSERT_EQUAL( |
| 7840 | password_expected, password_after, |
| 7841 | "append_base_password problem after inserting " + std::string(input)); |
| 7842 | #endif // ADA_DEVELOPMENT_CHECKS |
| 7843 | ADA_ASSERT_TRUE(validate()); |
| 7844 | } |
| 7845 | |
| 7846 | inline void url_aggregator::update_base_port(uint32_t input) { |
| 7847 | ada_log("url_aggregator::update_base_port"); |