Ensure blocked ips are deduped and empty strings removed

This commit is contained in:
Johannes Zellner
2020-09-12 20:53:12 +02:00
parent 63b212bea5
commit d9d1f13bf9

View File

@@ -82,7 +82,11 @@ angular.module('Application').controller('NetworkController', ['$scope', '$locat
$scope.blocklist.error = {};
$scope.blocklist.busy = true;
var blocklist = $scope.blocklist.blocklist.split('\n').filter(function (x) { return x !== ''; });
// remove empty and dedupe array
var blocklist = $scope.blocklist.blocklist.split('\n')
.map(function (ip) { return ip.trim(); })
.filter(function (ip) { return ip !== ''; })
.filter(function(item, pos, self) { return self.indexOf(item) == pos; });
Client.setBlocklist(blocklist, function (error) {
$scope.blocklist.busy = false;