gui: Use case-insensive and backslash-agnostic versions filter (fixes #7973) (#8995)

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 <twilczynski@naver.com>
This commit is contained in:
tomasz1986 2023-08-01 14:20:01 +02:00 committed by GitHub
parent 97625ccc26
commit 5323928159
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -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;
}