@@ -14,15 +14,18 @@ This library provides:
1414- A `skyr::url ` class that implements a generic URL parser,
1515 conforming with the WhatWG URL specification
1616- URL serialization and comparison
17+ - **Immutable URL transformations ** with `with_* ` methods for functional-style URL building
18+ - **URL sanitization ** methods to remove credentials, fragments, and query parameters
19+ - **Custom `std::format` support ** with format specifiers for URL components
1720- Percent encoding and decoding functions
1821- IDNA and Punycode functions for domain name parsing
19- - Basic Unicode conversion functions
22+ - Unicode conversion utilities
2023
2124Quick Start
2225-----------
2326
24- This project requires the availability of a C++17 compliant compiler
25- and standard library .
27+ This project requires a ** C++23 compliant compiler ** (GCC 13+, Clang 19+, MSVC 2022+)
28+ and has ** zero external dependencies ** for core URL parsing .
2629
27301. Download ``vcpkg `` and install the dependencies
2831^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -45,36 +48,24 @@ and standard library.
4548 // url_test.cpp
4649
4750 #include <skyr/url.hpp>
48- #include <skyr/percent_encoding/percent_decode .hpp>
49- #include <iostream >
51+ #include <skyr/url_format .hpp>
52+ #include <print >
5053
5154 int main() {
52- using namespace skyr::literals;
53-
54- try {
55- auto url =
56- "http://sub.example.إختبار:8090/\x cf\x 80?a=1&c=2&b=\x e2\x 80\x 8d\x f0\x 9f\x 8c\x 88"_url;
57-
58- std::cout << "Protocol: " << url.protocol() << std::endl;
59-
60- std::cout << "Domain? " << std::boolalpha << url.is_domain() << std::endl;
61- std::cout << "Domain: " << url.hostname() << std::endl;
62- std::cout << "Domain: "
63- << skyr::domain_to_u8(url.hostname()).value() << std::endl;
64-
65- std::cout << "Port: " << url.port<std::uint16_t>().value() << std::endl;
66-
67- std::cout << "Pathname: "
68- << skyr::percent_decode<std::string>(url.pathname()).value() << std::endl;
69-
70- std::cout << "Search parameters" << std::endl;
71- const auto &search = url.search_parameters();
72- for (const auto &[key, value] : search) {
73- std::cout << " " << "key: " << key << ", value = " << value << std::endl;
74- }
75- }
76- catch (const skyr::url_parse_error &e) {
77- std::cout << e.code().message() << std::endl;
55+ auto url = skyr::url("http://sub.example.إختبار:8090/\x cf\x 80?a=1&c=2&b=\x e2\x 80\x 8d\x f0\x 9f\x 8c\x 88");
56+
57+ // Using std::format support
58+ std::println("Scheme: {:s}", url);
59+ std::println("Domain? {}", url.is_domain());
60+ std::println("Domain: {:h}", url); // Encoded (punycode)
61+ std::println("Domain: {:hd}", url); // Decoded (unicode)
62+ std::println("Port: {:p}", url);
63+ std::println("Pathname: {:Pd}", url); // Decoded pathname
64+
65+ std::println("\n Search parameters:");
66+ const auto &search = url.search_parameters();
67+ for (const auto &[key, value] : search) {
68+ std::println(" key: {}, value = {}", key, value);
7869 }
7970 }
8071
@@ -85,12 +76,12 @@ and standard library.
8576
8677 # CMakeLists.txt
8778
79+ cmake_minimum_required(VERSION 3.21)
8880 project(my_project)
8981
90- find_package(tl-expected CONFIG REQUIRED)
9182 find_package(skyr-url CONFIG REQUIRED)
9283
93- set(CMAKE_CXX_STANDARD 17 )
84+ set(CMAKE_CXX_STANDARD 23 )
9485
9586 add_executable(url_test url_test.cpp)
9687 target_link_libraries(url_test PRIVATE skyr::skyr-url)
@@ -112,13 +103,13 @@ and standard library.
112103 Design objectives
113104^^^^^^^^^^^^^^^^^
114105
115- * Uses modern C++17 features
116- * Cross-platform
117- * Easy to use and read
118- * Compliant to the the WhatWG URL standard
119- * Works naturally with Unicode strings
120- * Uses modern CMake and is available as a dependency using a package
121- manager
106+ * Uses modern C++23 features (`` std::expected ``, `` std::format ``, `` std::ranges ``)
107+ * Header-only library with zero external dependencies
108+ * Cross-platform (Linux, macOS, Windows)
109+ * Easy to use and read with immutable, functional-style API
110+ * Compliant with the WhatWG URL specification
111+ * Works naturally with Unicode strings (IDNA/Punycode support)
112+ * Uses modern CMake and is available via vcpkg
122113
123114Documentation
124115-------------
0 commit comments