| 639 | } |
| 640 | |
| 641 | [[nodiscard]] std::string url::get_host() const { |
| 642 | // If url's host is null, then return the empty string. |
| 643 | // If url's port is null, return url's host, serialized. |
| 644 | // Return url's host, serialized, followed by U+003A (:) and url's port, |
| 645 | // serialized. |
| 646 | if (!host.has_value()) { |
| 647 | return ""; |
| 648 | } |
| 649 | if (port.has_value()) { |
| 650 | return host.value() + ":" + get_port(); |
| 651 | } |
| 652 | return host.value(); |
| 653 | } |
| 654 | |
| 655 | [[nodiscard]] std::string url::get_hostname() const { |
| 656 | return host.value_or(""); |