Lines Matching refs:url

10366 template ada::result<url> parse<url>(std::string_view input,
10367 const url* base_url = nullptr);
10521 // Let path be url's path.
10522 // If url's scheme is "file", path's size is 1, and path[0] is a normalized
10546 // Let path be url's path.
10547 // If url's scheme is "file", path's size is 1, and path[0] is a normalized
10893 * The spec at https://url.spec.whatwg.org/#hostname-state expects us to
11117 // If url's scheme is "file", url's path is empty, and path_buffer is a
11128 // Append path_buffer to url's path.
11150 url_type& url) noexcept {
11152 if (!url.has_opaque_path) return;
11153 if (url.has_hash()) return;
11154 if (url.has_search()) return;
11156 auto path = std::string(url.get_pathname());
11160 url.update_base_pathname(path);
11215 /* begin file src/url.cpp */
11223 bool url::parse_opaque_host(std::string_view input) {
11237 bool url::parse_ipv4(std::string_view input) {
11312 bool url::parse_ipv6(std::string_view input) {
11543 ada_really_inline bool url::parse_scheme(const std::string_view input) {
11552 // If url's scheme is not a special scheme and buffer is a special scheme,
11558 // If url includes credentials or has a non-null port, and buffer is
11565 // If url's scheme is "file" and its host is an empty host, then return.
11580 // If url's port is url's scheme's default port, then set url's port to
11596 // If url's scheme is a special scheme and buffer is not a special scheme,
11597 // then return. If url's scheme is not a special scheme and buffer is a
11603 // If url includes credentials or has a non-null port, and buffer is
11609 // If url's scheme is "file" and its host is an empty host, then return.
11624 // If url's port is url's scheme's default port, then set url's port to
11636 ada_really_inline bool url::parse_host(std::string_view input) {
11708 ada_really_inline void url::parse_path(std::string_view input) {
11722 // If url is special, then:
11748 [[nodiscard]] std::string url::to_string() const {
11797 [[nodiscard]] bool url::has_valid_domain() const noexcept {
11805 /* end file src/url.cpp */
11806 /* begin file src/url-getters.cpp */
11808 * @file url-getters.cpp
11809 * Includes all the getters of `ada::url`
11816 [[nodiscard]] std::string url::get_origin() const noexcept {
11827 auto result = ada::parse<ada::url>(path);
11842 [[nodiscard]] std::string url::get_protocol() const noexcept {
11850 [[nodiscard]] std::string url::get_host() const noexcept {
11851 // If url's host is null, then return the empty string.
11852 // If url's port is null, return url's host, serialized.
11853 // Return url's host, serialized, followed by U+003A (:) and url's port,
11864 [[nodiscard]] std::string url::get_hostname() const noexcept {
11868 [[nodiscard]] std::string_view url::get_pathname() const noexcept {
11872 [[nodiscard]] std::string url::get_search() const noexcept {
11879 [[nodiscard]] const std::string& url::get_username() const noexcept {
11883 [[nodiscard]] const std::string& url::get_password() const noexcept {
11887 [[nodiscard]] std::string url::get_port() const noexcept {
11891 [[nodiscard]] std::string url::get_hash() const noexcept {
11899 /* end file src/url-getters.cpp */
11900 /* begin file src/url-setters.cpp */
11902 * @file url-setters.cpp
11903 * Includes all the setters of `ada::url`
11912 bool url::set_host_or_hostname(const std::string_view input) {
11927 // If url's scheme is "file", then set state to file host state, instead of
11946 // If url is special and host_view is the empty string, validation error,
11948 // empty string, and either url includes credentials or url's port is
11955 // Let host be the result of host parsing host_view with url is not special.
11975 // Set url's host to the empty string.
11978 // Let host be the result of host parsing buffer with url is not special.
11993 bool url::set_host(const std::string_view input) {
11997 bool url::set_hostname(const std::string_view input) {
12001 bool url::set_username(const std::string_view input) {
12010 bool url::set_password(const std::string_view input) {
12019 bool url::set_port(const std::string_view input) {
12049 void url::set_hash(const std::string_view input) {
12064 void url::set_search(const std::string_view input) {
12083 bool url::set_pathname(const std::string_view input) {
12092 bool url::set_protocol(const std::string_view input) {
12116 bool url::set_href(const std::string_view input) {
12117 ada::result<ada::url> out = ada::parse<ada::url>(input);
12136 /* end file src/url-setters.cpp */
12151 // and ada::url **do not have to support the exact same API**.
12153 std::is_same<ada::url, result_type>::value;
12165 result_type url{};
12170 url.is_valid = false;
12176 url.is_valid &= base_url->is_valid;
12178 if (!url.is_valid) {
12179 return url;
12197 url.reserve(reserve_capacity);
12268 if (!url.parse_scheme(url_data.substr(0, input_position))) {
12269 return url;
12273 if (!url.parse_scheme_with_colon(
12275 return url;
12278 ada_log("SCHEME the scheme is ", url.get_protocol());
12280 // If url's scheme is "file", then:
12281 if (url.type == ada::scheme::type::FILE) {
12285 // Otherwise, if url is special, base is non-null, and base's scheme
12286 // is url's scheme: Note: Doing base_url->scheme is unsafe if base_url
12288 else if (url.is_special() && base_url != nullptr &&
12289 base_url->type == url.type) {
12293 // Otherwise, if url is special, set state to special authority
12295 else if (url.is_special()) {
12305 // Otherwise, set url's path to the empty string and set state to
12329 url.is_valid = false;
12330 return url;
12333 // set url's scheme to base's scheme, url's path to base's path, url's
12338 url.copy_scheme(*base_url);
12339 url.has_opaque_path = base_url->has_opaque_path;
12342 url.path = base_url->path;
12343 url.query = base_url->query;
12345 url.update_base_pathname(base_url->get_pathname());
12346 url.update_base_search(base_url->get_search());
12348 url.update_unencoded_base_hash(*fragment);
12349 return url;
12392 url.is_special() ? helpers::find_authority_delimiter_special(view)
12403 url.password += "%40";
12405 url.append_base_password("%40");
12409 url.username += "%40";
12411 url.append_base_username("%40");
12425 url.username += unicode::percent_encode(
12428 url.append_base_username(unicode::percent_encode(
12433 url.username += unicode::percent_encode(
12436 url.password += unicode::percent_encode(
12440 url.append_base_username(unicode::percent_encode(
12443 url.append_base_password(unicode::percent_encode(
12450 url.password += unicode::percent_encode(
12453 url.append_base_password(unicode::percent_encode(
12460 // - url is special and c is U+005C (\)
12464 (url.is_special() && url_data[end_of_authority] == '\\')) {
12468 url.is_valid = false;
12469 return url;
12476 url.update_unencoded_base_hash(*fragment);
12478 return url;
12524 // Set url's scheme to base's scheme.
12525 url.copy_scheme(*base_url);
12534 } else if (url.is_special() && (input_position != input_size) &&
12536 // Otherwise, if url is special and c is U+005C (\), validation error,
12539 "RELATIVE_SCHEME if url is special and c is U+005C, validation "
12544 // Set url's username to base's username, url's password to base's
12545 // password, url's host to base's host, url's port to base's port,
12546 // url's path to a clone of base's path, and url's query to base's
12549 url.username = base_url->username;
12550 url.password = base_url->password;
12551 url.host = base_url->host;
12552 url.port = base_url->port;
12554 url.has_opaque_path = base_url->has_opaque_path;
12555 url.path = base_url->path;
12556 url.query = base_url->query;
12558 url.update_base_authority(base_url->get_href(),
12562 url.set_hostname(base_url->get_hostname());
12563 url.update_base_port(base_url->retrieve_base_port());
12565 url.has_opaque_path = base_url->has_opaque_path;
12566 url.update_base_pathname(base_url->get_pathname());
12567 url.update_base_search(base_url->get_search());
12570 url.has_opaque_path = base_url->has_opaque_path;
12572 // If c is U+003F (?), then set url's query to the empty string, and
12580 // Set url's query to null.
12581 url.clear_search();
12583 // Shorten url's path.
12584 helpers::shorten_path(url.path, url.type);
12586 std::string_view path = url.get_pathname();
12587 if (helpers::shorten_path(path, url.type)) {
12588 url.update_base_pathname(std::string(path));
12603 // If url is special and c is U+002F (/) or U+005C (\), then:
12604 if (url.is_special() && (input_position != input_size) &&
12616 // - url's username to base's username,
12617 // - url's password to base's password,
12618 // - url's host to base's host,
12619 // - url's port to base's port,
12623 url.username = base_url->username;
12624 url.password = base_url->password;
12625 url.host = base_url->host;
12626 url.port = base_url->port;
12628 url.update_base_authority(base_url->get_href(),
12632 url.set_hostname(base_url->get_hostname());
12633 url.update_base_port(base_url->retrieve_base_port());
12674 // url is special; otherwise the query percent-encode set.
12676 url.is_special() ? ada::character_sets::SPECIAL_QUERY_PERCENT_ENCODE
12680 // queryPercentEncodeSet, and append the result to url's query.
12681 url.update_base_search(helpers::substring(url_data, input_position),
12685 url.update_unencoded_base_hash(*fragment);
12687 return url;
12695 helpers::get_host_delimiter_location(url.is_special(), host_view);
12704 // Let host be the result of host parsing buffer with url is not
12707 if (!url.parse_host(host_view)) {
12708 return url;
12710 ada_log("HOST parsing results in ", url.get_hostname());
12711 // Set url's host to host, buffer to the empty string, and state to
12718 // - url is special and c is U+005C (\)
12722 // If url is special and host_view is the empty string, validation
12724 if (url.is_special() && host_view.empty()) {
12725 url.is_valid = false;
12726 return url;
12728 ada_log("HOST parsing ", host_view, " href=", url.get_href());
12729 // Let host be the result of host parsing host_view with url is not
12732 url.update_base_hostname("");
12733 } else if (!url.parse_host(host_view)) {
12734 return url;
12736 ada_log("HOST parsing results in ", url.get_hostname(),
12737 " href=", url.get_href());
12739 // Set url's host to host, and state to path start state.
12748 // If c is U+003F (?), then set url's query to the empty string and
12758 url.has_opaque_path = true;
12761 url.update_base_pathname(unicode::percent_encode(
12769 size_t consumed_bytes = url.parse_port(port_view, true);
12771 if (!url.is_valid) {
12772 return url;
12780 // If url is special, then:
12781 if (url.is_special()) {
12788 url.update_base_pathname("/");
12790 url.update_unencoded_base_hash(*fragment);
12792 return url;
12803 // set url's query to the empty string and state to query state.
12837 helpers::parse_prepared_path(view, url.type, url.path);
12839 url.consume_prepared_path(view);
12840 ADA_ASSERT_TRUE(url.validate());
12862 // Set url's host to base's host.
12864 url.host = base_url->host;
12867 url.set_host(base_url->get_host());
12872 // url's path.
12885 url.path += '/';
12886 url.path += first_base_url_path;
12888 url.append_base_pathname(
12914 // Set url's host to the empty string.
12916 url.host = "";
12918 url.update_base_hostname("");
12925 // Let host be the result of host parsing buffer with url is not
12927 if (!url.parse_host(file_host_buffer)) {
12928 return url;
12933 if (url.host.has_value() && url.host.value() == "localhost") {
12934 url.host = "";
12937 if (url.get_hostname() == "localhost") {
12938 url.update_base_hostname("");
12953 url.set_protocol_as_file();
12955 // Set url's host to the empty string.
12956 url.host = "";
12958 url.update_base_hostname("");
12971 // Set url's host to base's host, url's path to a clone of base's
12972 // path, and url's query to base's query.
12975 url.host = base_url->host;
12976 url.path = base_url->path;
12977 url.query = base_url->query;
12981 url.set_hostname(base_url->get_hostname());
12982 url.update_base_pathname(base_url->get_pathname());
12983 url.update_base_search(base_url->get_search());
12985 url.has_opaque_path = base_url->has_opaque_path;
12987 // If c is U+003F (?), then set url's query to the empty string and
12994 // Set url's query to null.
12995 url.clear_search();
12997 // not start with a Windows drive letter, then shorten url's path.
13000 helpers::shorten_path(url.path, url.type);
13002 std::string_view path = url.get_pathname();
13003 if (helpers::shorten_path(path, url.type)) {
13004 url.update_base_pathname(std::string(path));
13010 // Set url's path to an empty list.
13011 url.clear_pathname();
13012 url.has_opaque_path = true;
13035 url.update_unencoded_base_hash(*fragment);
13037 return url;
13040 template url parse_url<url>(std::string_view user_input,
13041 const url* base_url = nullptr);
13195 // If url's scheme is not a special scheme and buffer is a special scheme,
13201 // If url includes credentials or has a non-null port, and buffer is
13208 // If url's scheme is "file" and its host is an empty host, then return.
13223 // If url's port is url's scheme's default port, then set url's port to
13237 // If url's scheme is a special scheme and buffer is not a special scheme,
13238 // then return. If url's scheme is not a special scheme and buffer is a
13244 // If url includes credentials or has a non-null port, and buffer is
13251 // If url's scheme is "file" and its host is an empty host, then return.
13265 // If url's port is url's scheme's default port, then set url's port to
13507 // If url is special, then:
13696 // If url's scheme is "file", then set state to file host state, instead of
13715 // If url is special and host_view is the empty string, validation error,
13717 // empty string, and either url includes credentials or url's port is
13724 // Let host be the result of host parsing host_view with url is not special.
13752 // Set url's host to the empty string.
13755 // Let host be the result of host parsing buffer with url is not special.
14121 // TODO: Find a way to merge parse_ipv6 with url.cpp implementation.
14871 // If url's scheme is "file", url's path is empty, and path_buffer is a
14882 // Append path_buffer to url's path.