Utils: Add a private FilePath::encodedHost() helper

Change-Id: I7ce1c7e1e892b3a14f9d31e106b58e8340d574d8
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
hjk
2022-09-02 16:47:54 +02:00
parent b94d4f75d0
commit ba2956984c
2 changed files with 7 additions and 5 deletions

View File

@@ -172,8 +172,9 @@ FilePath FilePath::rootPath()
return FilePath::fromString(QDir::rootPath());
}
static QString hostEncoded(QString host)
QString FilePath::encodedHost() const
{
QString host = m_host;
host.replace('%', "%25");
host.replace('/', "%2f");
return host;
@@ -186,8 +187,8 @@ QString FilePath::toString() const
return m_path;
if (isRelativePath())
return specialPath(SpecialPathComponent::RootPath) + "/" + m_scheme + "/" + hostEncoded(m_host) + "/./" + m_path;
return specialPath(SpecialPathComponent::RootPath) + "/" + m_scheme + "/" + hostEncoded(m_host) + m_path;
return specialPath(SpecialPathComponent::RootPath) + "/" + m_scheme + "/" + encodedHost() + "/./" + m_path;
return specialPath(SpecialPathComponent::RootPath) + "/" + m_scheme + "/" + encodedHost() + m_path;
}
QString FilePath::toFSPathString() const
@@ -212,8 +213,8 @@ QString FilePath::toUserOutput() const
{
if (needsDevice()) {
if (root().empty())
return m_scheme + "://" + hostEncoded(m_host) + "/./" + m_path;
return m_scheme + "://" + hostEncoded(m_host) + m_path;
return m_scheme + "://" + encodedHost() + "/./" + m_path;
return m_scheme + "://" + encodedHost() + m_path;
}
QString tmp = toString();