From 50729c19ebf75ab91ee285fe7af86abbdaec411c Mon Sep 17 00:00:00 2001 From: Mike Skec Date: Thu, 7 Jan 2021 08:35:25 +1100 Subject: Fixes pages not being read from cache due to differing trailing slash Also fixes favourites with the same problem --- src/ioutil.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/ioutil.cpp') 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); +} -- cgit v1.2.3