FilePath: Fix setFromString for short urls

FilePath::setFromString failed previously for URLs
without a path, e.g. "http://qt.io" as it would add
the scheme and host to its path.

Also added a test for various URLs

Change-Id: I6c22489c0af7154734390aa1e5e12693864210b1
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Marcus Tillmanns
2022-08-31 08:31:09 +02:00
parent e9d6c0f154
commit 1af0eb3504
2 changed files with 33 additions and 1 deletions

View File

@@ -875,7 +875,8 @@ void FilePath::setFromString(const QString &filename, OsType osType)
m_scheme = filename.left(schemeEnd);
const auto hostEnd = filename.indexOf(slash, schemeEnd + 3);
m_host = filename.mid(schemeEnd + 3, hostEnd - schemeEnd - 3);
setRootAndPath(QStringView(filename).mid(hostEnd), osType);
if (hostEnd != -1)
setRootAndPath(QStringView(filename).mid(hostEnd), osType);
return;
}