From 53239281593cba4192d592ac694958876a184d84 Mon Sep 17 00:00:00 2001 From: tomasz1986 Date: Tue, 1 Aug 2023 14:20:01 +0200 Subject: [PATCH] gui: Use case-insensive and backslash-agnostic versions filter (fixes #7973) (#8995) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, the versions filter is case-sensitive regardless of the underlying OS. With this change, the filter becomes case-insensitive everywhere, which is more user-friendly and makes it easier to search for files whose exact case the user may not remember. In addition, forward and backslashes are no longer distinguished, whether used as path separators or as part of a file / directory name (which is unlikely but possible on some platforms). Signed-off-by: Tomasz WilczyƄski --- gui/default/syncthing/core/syncthingController.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gui/default/syncthing/core/syncthingController.js b/gui/default/syncthing/core/syncthingController.js index adca42026..4163d020a 100755 --- a/gui/default/syncthing/core/syncthingController.js +++ b/gui/default/syncthing/core/syncthingController.js @@ -2778,9 +2778,17 @@ angular.module('syncthing.core') $scope.restoreVersions.tree.filterNodes(function (node) { if (node.folder) return false; - if ($scope.restoreVersions.filters.text && node.key.indexOf($scope.restoreVersions.filters.text) < 0) { - return false; + + if ($scope.restoreVersions.filters.text) { + // Use case-insensitive filter and convert backslashes to + // forward slashes to allow using them as path separators. + var filterText = $scope.restoreVersions.filters.text.toLowerCase().replace(/\\/g, '/'); + var versionPath = node.key.toLowerCase().replace(/\\/g, '/'); + if (versionPath.indexOf(filterText) < 0) { + return false; + } } + if ($scope.restoreVersions.filterVersions(node.data.versions).length == 0) { return false; }