diff options
author | hjk <hjk@qt.io> | 2022-11-29 12:58:47 +0100 |
---|---|---|
committer | hjk <hjk@qt.io> | 2022-11-30 11:47:33 +0000 |
commit | 4eee8a12fb71b5404a47202d7d8fe3cd733cd029 (patch) | |
tree | 67cb6ae27703db7db445c07cc6d59c828ead292d | |
parent | 8679138f73acf201636e957ba772a4a673778c96 (diff) |
Utils: Clean path in FilePath::resolvePath
Change-Id: I27e34e21c2922db4d7598c77688133aebf6ce893
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
-rw-r--r-- | src/libs/utils/filepath.cpp | 5 | ||||
-rw-r--r-- | tests/auto/utils/fileutils/tst_fileutils.cpp | 4 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/libs/utils/filepath.cpp b/src/libs/utils/filepath.cpp index 1680f9483e..13aa1b3f6b 100644 --- a/src/libs/utils/filepath.cpp +++ b/src/libs/utils/filepath.cpp @@ -1263,9 +1263,8 @@ FilePath FilePath::pathAppended(const QString &path) const FilePath other = FilePath::fromString(path); - if (isEmpty()) { + if (isEmpty()) return other; - } QString p = this->path(); join(p, other.path()); @@ -1549,7 +1548,7 @@ bool FilePath::isRelativePath() const FilePath FilePath::resolvePath(const FilePath &tail) const { if (tail.isRelativePath()) - return pathAppended(tail.path()); + return pathAppended(tail.path()).cleanPath(); return tail; } diff --git a/tests/auto/utils/fileutils/tst_fileutils.cpp b/tests/auto/utils/fileutils/tst_fileutils.cpp index c75f0e9efd..dd3c5de097 100644 --- a/tests/auto/utils/fileutils/tst_fileutils.cpp +++ b/tests/auto/utils/fileutils/tst_fileutils.cpp @@ -84,8 +84,10 @@ private slots: void bytesAvailableFromDF_data(); void bytesAvailableFromDF(); + void rootLength_data(); void rootLength(); + void schemeAndHostLength_data(); void schemeAndHostLength(); @@ -852,6 +854,8 @@ void tst_fileutils::resolvePath_data() QTest::newRow("s4") << FilePath("/a") << FilePath("/b") << FilePath("/b"); QTest::newRow("s5") << FilePath("a") << FilePath("/b") << FilePath("/b"); QTest::newRow("s6") << FilePath("/a") << FilePath("b") << FilePath("/a/b"); + QTest::newRow("s7") << FilePath("/a") << FilePath(".") << FilePath("/a"); + QTest::newRow("s8") << FilePath("/a") << FilePath("./b") << FilePath("/a/b"); } void tst_fileutils::resolvePath() |