From 79048812e956e80ee464a1cd1373bc15caea5b1e Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Thu, 17 Dec 2020 21:23:31 +0300 Subject: [PATCH] Fix folder name extraction functions It should return empty string if there is no parent folder. --- src/base/utils/fs.cpp | 2 +- src/webui/www/private/scripts/filesystem.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/base/utils/fs.cpp b/src/base/utils/fs.cpp index 6d9381304..e48429f3f 100644 --- a/src/base/utils/fs.cpp +++ b/src/base/utils/fs.cpp @@ -95,7 +95,7 @@ QString Utils::Fs::folderName(const QString &filePath) const QString path = toUniformPath(filePath); const int slashIndex = path.lastIndexOf('/'); if (slashIndex == -1) - return path; + return {}; return path.left(slashIndex); } diff --git a/src/webui/www/private/scripts/filesystem.js b/src/webui/www/private/scripts/filesystem.js index 0cd87241f..dc208d6e5 100644 --- a/src/webui/www/private/scripts/filesystem.js +++ b/src/webui/www/private/scripts/filesystem.js @@ -70,7 +70,7 @@ window.qBittorrent.Filesystem = (function() { const folderName = function(filepath) { const slashIndex = filepath.lastIndexOf(PathSeparator); if (slashIndex === -1) - return filepath; + return ''; return filepath.substring(0, slashIndex); };