diff --git a/test/spec/groupCtrlSpec.js b/test/spec/groupCtrlSpec.js index 5b2ecd60e5..7416c90a4e 100644 --- a/test/spec/groupCtrlSpec.js +++ b/test/spec/groupCtrlSpec.js @@ -133,6 +133,11 @@ describe("Autocomplete controller", function() { expect(scope.filterUser({user: "prefix"})).to.be.eq(true); }); + it('filters with prefix of a different case and element and returns true', function() { + scope.query = {text: "pre"} + expect(scope.filterUser({user: "Prefix"})).to.be.eq(true); + }); + it('filters with nonprefix element and returns false', function() { scope.query = {text: "noprefix"} expect(scope.filterUser({user: "prefix"})).to.be.eq(false); diff --git a/website/public/js/controllers/groupsCtrl.js b/website/public/js/controllers/groupsCtrl.js index 0f1744dc66..26a4196a97 100644 --- a/website/public/js/controllers/groupsCtrl.js +++ b/website/public/js/controllers/groupsCtrl.js @@ -225,7 +225,11 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', ' return false; } - return msg.user.indexOf($scope.query.text) == 0; + // Ignore casing when checking for username + var user = msg.user.toLowerCase(); + var text = $scope.query.text.toLowerCase(); + + return user.indexOf(text) == 0; } $scope.addNewUser = function(user) {