aboutsummaryrefslogtreecommitdiff
path: root/libbutl/url.ixx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-09-29 00:12:26 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-10-09 21:07:02 +0300
commitec9c6f1bbdfd3d86fba493ea56473c0aaf9acad1 (patch)
tree85f063f5fa0ea307d0c8f67e39fdfdd93731cb89 /libbutl/url.ixx
parent758b64bcf02d9269ae4765ab98d7d46396b3e69a (diff)
Add support for rootless URLs
Diffstat (limited to 'libbutl/url.ixx')
-rw-r--r--libbutl/url.ixx36
1 files changed, 36 insertions, 0 deletions
diff --git a/libbutl/url.ixx b/libbutl/url.ixx
index 2feb347..7a6d86f 100644
--- a/libbutl/url.ixx
+++ b/libbutl/url.ixx
@@ -4,6 +4,28 @@
LIBBUTL_MODEXPORT namespace butl //@@ MOD Clang needs this for some reason.
{
+ // url_traits
+ //
+ template <typename H, typename S, typename P>
+ inline typename url_traits<H, S, P>::path_type url_traits<H, S, P>::
+ translate_path (string_type&& path)
+ {
+ return path_type (basic_url<string_type>::decode (path));
+ }
+
+ template <typename H, typename S, typename P>
+ inline typename url_traits<H, S, P>::string_type url_traits<H, S, P>::
+ translate_path (const path_type& path)
+ {
+ using url = basic_url<string_type>;
+
+ return url::encode (
+ string_type (path),
+ [] (typename url::char_type& c) {return !url::path_char (c);});
+ }
+
+ // basic_url
+ //
template <typename S, typename T>
inline basic_url<S, T>::
basic_url (scheme_type s,
@@ -81,4 +103,18 @@ LIBBUTL_MODEXPORT namespace butl //@@ MOD Clang needs this for some reason.
std::move (f))
{
}
+
+ template <typename S, typename T>
+ inline basic_url<S, T>::
+ basic_url (scheme_type s,
+ optional<path_type> p,
+ optional<string_type> q,
+ optional<string_type> f)
+ : scheme (std::move (s)),
+ path (std::move (p)),
+ query (std::move (q)),
+ fragment (std::move (f)),
+ rootless (true)
+ {
+ }
}