Repository: syncthing/syncthing
File: gui/default/syncthing/core/syncthingController.js (JavaScript)

Code before:
                                // Force angular to wake up.
                                $timeout(function () {
                                    $scope.$apply();
                                });
                            });
                        });
                    });
                }
            };
        }
        resetRestoreVersions();

        $scope.$watchCollection('restoreVersions.filters', function () {
            if (!$scope.restoreVersions.tree) return;

            $scope.restoreVersions.tree.filterNodes(function (node) {
                if (node.folder) return false;

                if ($scope.restoreVersions.filters.text) {
                    // Use case-insensitive filter.
                    var filterText = $scope.restoreVersions.filters.text.toLowerCase();
                    var versionPath = node.key.toLowerCase();
                    // Allow backslashes on Windows as filter path separators.
                    if ($scope.version.os == 'windows') {
                        filterText = filterText.replace(/\//g, '\\');
                        versionPath = versionPath.replace(/\//g, '\\');
                    }
                    if (versionPath.indexOf(filterText) < 0) {
                        return false;
                    }
                }

                if ($scope.restoreVersions.filterVersions(node.data.versions).length == 0) {
                    return false;
                }
                return true;
            });
        });

        $scope.setAPIKey = function (cfg) {
            $http.get(urlbase + '/svc/random/string?length=32').success(function (data) {
                cfg.apiKey = data.random;
            });
        };

        $scope.acceptUR = function () {
            $scope.config.options.urAccepted = $scope.system.urVersionMax;
            $scope.config.options.urSeen = $scope.system.urVersionMax;
            $scope.saveConfig();
            $('#ur').modal('hide');
        };

Review comment (suggestion):
If I understand this correctly, you're replacing every slash with a backslash on Windows?  The regex is kinda hard to read because of all the slashes involved for different purposes.

Why not go the other way round?  Doesn't Syncthing use forward-slashes for relative paths within a folder?  Converting backslashes to slashes would make more sense to me, as it reduces differences between OSes.

Code after:
                                // Force angular to wake up.
                                $timeout(function () {
                                    $scope.$apply();
                                });
                            });
                        });
                    });
                }
            };
        }
        resetRestoreVersions();

        $scope.$watchCollection('restoreVersions.filters', function () {
            if (!$scope.restoreVersions.tree) return;

            $scope.restoreVersions.tree.filterNodes(function (node) {
                if (node.folder) 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;
                }
                return true;
            });
        });

        $scope.setAPIKey = function (cfg) {
            $http.get(urlbase + '/svc/random/string?length=32').success(function (data) {
                cfg.apiKey = data.random;
            });
        };

        $scope.acceptUR = function () {
            $scope.config.options.urAccepted = $scope.system.urVersionMax;
            $scope.config.options.urSeen = $scope.system.urVersionMax;
            $scope.saveConfig();
            $('#ur').modal('hide');
        };

        $scope.declineUR = function () {
            if ($scope.config.options.urAccepted === 0) {
                $scope.config.options.urAccepted = -1;