summaryrefslogtreecommitdiff
path: root/src/utils/stringutils.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-04-15 20:17:18 +0300
committerAndrei Karas <akaras@inbox.ru>2017-04-15 20:17:18 +0300
commit482981410f52fff5b3e721bd51ce31c118bdaeaf (patch)
treedbb2e80d62763ed1977a96ad549310c5a28230e3 /src/utils/stringutils.cpp
parent820fc2d2509cda0648ceb33a860e25249b633bb8 (diff)
downloadplus-482981410f52fff5b3e721bd51ce31c118bdaeaf.tar.gz
plus-482981410f52fff5b3e721bd51ce31c118bdaeaf.tar.bz2
plus-482981410f52fff5b3e721bd51ce31c118bdaeaf.tar.xz
plus-482981410f52fff5b3e721bd51ce31c118bdaeaf.zip
Fix download urls on windows.v1.7.4.15
Diffstat (limited to 'src/utils/stringutils.cpp')
-rw-r--r--src/utils/stringutils.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index 5a343cdbd..90d5835a5 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -1143,6 +1143,43 @@ std::string pathJoin(std::string str1,
}
}
+std::string urlJoin(std::string str1,
+ const std::string &str2)
+{
+ const char sep = '/';
+ std::string sepStr = "/";
+
+ if (str1.empty())
+ {
+ if (str2[0] == sep)
+ return str2;
+ else
+ return sepStr.append(str2);
+ }
+ const size_t sz1 = str1.size();
+ if (str2.empty())
+ {
+ if (str1[sz1 - 1] == sep)
+ return str1;
+ else
+ return str1.append(sepStr);
+ }
+ if (str1[sz1 - 1] == sep)
+ {
+ if (str2[0] == sep)
+ return str1.append(str2.substr(1));
+ else
+ return str1.append(str2);
+ }
+ else
+ {
+ if (str2[0] == sep)
+ return str1.append(str2);
+ else
+ return str1.append(sepStr).append(str2);
+ }
+}
+
#ifndef DYECMD
void replaceItemLinks(std::string &msg)
{