aboutsummaryrefslogtreecommitdiff
path: root/src/ioutil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ioutil.cpp')
-rw-r--r--src/ioutil.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/ioutil.cpp b/src/ioutil.cpp
index 00caba6..6257877 100644
--- a/src/ioutil.cpp
+++ b/src/ioutil.cpp
@@ -34,3 +34,18 @@ QString IoUtil::size_human(qint64 size)
}
return QString().setNum(num,'f',2)+" "+unit;
}
+
+QUrl IoUtil::uniformUrl(QUrl url)
+{
+ // We have to manually strip the root path slash
+ // since StripTrailingSlash doesn't strip it for some reason.
+ if (url.path() == "/") url.setPath(QString { });
+
+ // This will strip slashes from non-root paths
+ return url.adjusted(QUrl::RemoveFragment | QUrl::StripTrailingSlash);
+}
+
+QString IoUtil::uniformUrlString(QUrl url)
+{
+ return IoUtil::uniformUrl(url).toString(QUrl::FullyEncoded);
+}