Skip to content

Commit 46cc449

Browse files
authored
Renamed domain_to_unicode to domain_to_u8 (#121)
1 parent db2791c commit 46cc449

File tree

6 files changed

+10
-8
lines changed

6 files changed

+10
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ int main() {
137137
std::cout << "Domain? " << std::boolalpha << url.is_domain() << std::endl;
138138
std::cout << "Domain: " << url.hostname() << std::endl;
139139
std::cout << "Domain: "
140-
<< skyr::domain_to_unicode(url.hostname()).value() << std::endl;
140+
<< skyr::domain_to_u8(url.hostname()).value() << std::endl;
141141

142142
std::cout << "Port: " << url.port<std::uint16_t>().value() << std::endl;
143143

docs/index.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,14 @@ and standard library.
5959

6060
std::cout << "Domain? " << std::boolalpha << url.is_domain() << std::endl;
6161
std::cout << "Domain: " << url.hostname() << std::endl;
62-
63-
std::cout << "Pathname: " <<
64-
skyr::percent_decode<std::string>(url.pathname()).value() << std::endl;
62+
std::cout << "Domain: "
63+
<< skyr::domain_to_u8(url.hostname()).value() << std::endl;
6564

6665
std::cout << "Port: " << url.port<std::uint16_t>().value() << std::endl;
6766

67+
std::cout << "Pathname: "
68+
<< skyr::percent_decode<std::string>(url.pathname()).value() << std::endl;
69+
6870
std::cout << "Search parameters" << std::endl;
6971
const auto &search = url.search_parameters();
7072
for (const auto &[key, value] : search) {

include/skyr/v1/domain/domain.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ inline auto domain_to_ascii(std::string_view domain) {
6262
///
6363
/// \param ascii A Punycode encoded domain
6464
/// \returns A valid UTF-8 encoded domain, or an error
65-
auto domain_to_unicode(std::string_view ascii) -> tl::expected<std::string, domain_errc>;
65+
auto domain_to_u8(std::string_view ascii) -> tl::expected<std::string, domain_errc>;
6666
} // namespace v1
6767
} // namespace skyr
6868

src/v1/domain/domain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ auto domain_to_ascii(
159159
return domain_to_ascii(utf32.value(), be_strict, validation_error);
160160
}
161161

162-
auto domain_to_unicode(std::string_view ascii) -> tl::expected<std::string, domain_errc> {
162+
auto domain_to_u8(std::string_view ascii) -> tl::expected<std::string, domain_errc> {
163163
auto labels = std::vector<std::string>{};
164164
for (auto label : split(ascii, ".")) {
165165
if (label.substr(0, 4) == "xn--") {

src/v1/url/url.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ auto url::ipv6_address() const -> std::optional<skyr::ipv6_address> {
176176
}
177177

178178
[[nodiscard]] auto url::domain() const -> std::optional<string_type> {
179-
return is_domain()? std::make_optional(skyr::domain_to_unicode(hostname()).value()) : std::nullopt;
179+
return is_domain()? std::make_optional(skyr::domain_to_u8(hostname()).value()) : std::nullopt;
180180
}
181181

182182
auto url::set_port(string_view port) -> std::error_code {

tests/domain/domain_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ TEST_CASE("valid domains from ascii", "[domain]") {
4343

4444
SECTION("ascii_to_domain_tests") {
4545
const auto &[expected, input] = domain;
46-
auto instance = skyr::domain_to_unicode(input);
46+
auto instance = skyr::domain_to_u8(input);
4747
REQUIRE(instance);
4848
CHECK(expected == instance.value());
4949
}

0 commit comments

Comments
 (0)