]> git.tdb.fi Git - libs/net.git/blobdiff - source/http/utils.cpp
Use the append function from string utilities
[libs/net.git] / source / http / utils.cpp
index 8aa966cd09fc88a45092d46b4d37e72323beb9c3..7e1037e693d42094679d59ec905375eb6cd81ffe 100644 (file)
@@ -106,16 +106,8 @@ string build_url(const Url &url)
                str += url.scheme+"://";
        str += url.host;
        str += urlencode(url.path);
-       if(!url.query.empty())
-       {
-               str += '?';
-               str += url.query;
-       }
-       if(!url.fragment.empty())
-       {
-               str += '#';
-               str += url.fragment;
-       }
+       append(str, "?", url.query);
+       append(str, "#", url.fragment);
        return str;
 }
 
@@ -137,9 +129,7 @@ string build_query(const Query &query)
        string str;
        for(const auto &kvp: query)
        {
-               if(!str.empty())
-                       str += '&';
-               str += urlencode_plus(kvp.first);
+               append(str, "&", urlencode_plus(kvp.first));
                str += '=';
                str += urlencode_plus(kvp.second);
        }