Docker: Make hostname valid for Urls

Change-Id: I026aee70503699fcada30948195a7ebd4c76aeb0
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Marcus Tillmanns
2022-12-02 13:29:00 +01:00
parent 0f4430ca05
commit 79c2984222
2 changed files with 9 additions and 3 deletions

View File

@@ -150,6 +150,7 @@ public:
DockerSettings *settings() { return m_settings; } DockerSettings *settings() { return m_settings; }
QString repoAndTag() const { return m_data.repoAndTag(); } QString repoAndTag() const { return m_data.repoAndTag(); }
QString repoAndTagEncoded() const { return m_data.repoAndTagEncoded(); }
QString dockerImageId() const { return m_data.imageId; } QString dockerImageId() const { return m_data.imageId; }
Environment environment(); Environment environment();
@@ -770,7 +771,7 @@ FilePath DockerDevice::mapToGlobalPath(const FilePath &pathOnDevice) const
} }
return FilePath::fromParts(Constants::DOCKER_DEVICE_SCHEME, return FilePath::fromParts(Constants::DOCKER_DEVICE_SCHEME,
d->repoAndTag(), d->repoAndTagEncoded(),
pathOnDevice.path()); pathOnDevice.path());
// The following would work, but gives no hint on repo and tag // The following would work, but gives no hint on repo and tag
@@ -784,7 +785,7 @@ FilePath DockerDevice::mapToGlobalPath(const FilePath &pathOnDevice) const
Utils::FilePath DockerDevice::rootPath() const Utils::FilePath DockerDevice::rootPath() const
{ {
return FilePath::fromParts(Constants::DOCKER_DEVICE_SCHEME, d->repoAndTag(), u"/"); return FilePath::fromParts(Constants::DOCKER_DEVICE_SCHEME, d->repoAndTagEncoded(), u"/");
} }
bool DockerDevice::handlesFile(const FilePath &filePath) const bool DockerDevice::handlesFile(const FilePath &filePath) const
@@ -797,7 +798,10 @@ bool DockerDevice::handlesFile(const FilePath &filePath) const
if (isDockerScheme && filePath.host() == d->dockerImageId()) if (isDockerScheme && filePath.host() == d->dockerImageId())
return true; return true;
if (isDockerScheme && filePath.host() == QString(d->repoAndTag())) if (isDockerScheme && filePath.host() == d->repoAndTagEncoded())
return true;
if (isDockerScheme && filePath.host() == d->repoAndTag())
return true; return true;
return false; return false;

View File

@@ -39,6 +39,8 @@ public:
return repo + ':' + tag; return repo + ':' + tag;
} }
QString repoAndTagEncoded() const { return repoAndTag().replace(':', '.'); }
QString imageId; QString imageId;
QString repo; QString repo;
QString tag; QString tag;