From d6be03febf125993446eb66c96980553dba49dbf Mon Sep 17 00:00:00 2001 From: yggverse Date: Wed, 14 Aug 2024 21:09:53 +0300 Subject: [PATCH] implement Url::to_string --- src/lib/url.cpp | 13 +++++++++++++ src/lib/url.hpp | 2 ++ 2 files changed, 15 insertions(+) diff --git a/src/lib/url.cpp b/src/lib/url.cpp index fd50ebf3..57758c40 100644 --- a/src/lib/url.cpp +++ b/src/lib/url.cpp @@ -25,4 +25,17 @@ Url::Url( query = results[5]; } +string Url::to_string() +{ + string result; + + if (!scheme.empty()) result += scheme + "://"; + if (!host.empty()) result += host; + if (!port.empty()) result += ":" + port; + if (!path.empty()) result += "/" + path; + if (!query.empty()) result += "?" + query; + + return result; +} + Url::~Url() = default; \ No newline at end of file diff --git a/src/lib/url.hpp b/src/lib/url.hpp index d7756108..62abb79a 100644 --- a/src/lib/url.hpp +++ b/src/lib/url.hpp @@ -20,6 +20,8 @@ namespace lib std::string subject ); + std::string to_string(); + ~Url(); }; }