Fix bug where nicks could be missing the first char(s) in the nicklist
authorJack Allnutt <jack@allnutt.eu>
Thu, 26 Sep 2013 18:46:08 +0000 (19:46 +0100)
committerJack Allnutt <jack@allnutt.eu>
Thu, 26 Sep 2013 18:46:08 +0000 (19:46 +0100)
When a nick contains a PREFIX symbol that isn't at the beginning of
the nick, the _kiwi.model.Member#stripPrefix function would still
count it as a part of the prefix and remove an unrelated character
from the front of the nick.

client/assets/src/models/member.js

index 4e1f580ceb9441b97db9ab05f645013629e4585b..70bf75ecaad004e3f7c679a9c1e19ac4af5154fa 100644 (file)
@@ -76,7 +76,7 @@ _kiwi.model.Member = Backbone.Model.extend({
         return prefix;\r
     },\r
     stripPrefix: function (nick) {\r
-        var tmp = nick, i, j, k;\r
+        var tmp = nick, i, j, k, cont = false;\r
         var user_prefixes = _kiwi.gateway.get('user_prefixes');\r
         i = 0;\r
 \r
@@ -84,9 +84,14 @@ _kiwi.model.Member = Backbone.Model.extend({
             for (k = 0; k < user_prefixes.length; k++) {\r
                 if (nick.charAt(j) === user_prefixes[k].symbol) {\r
                     i++;\r
+                    cont = true;\r
                     break;\r
                 }\r
             }\r
+            if (!cont) {\r
+                break;\r
+            }\r
+            cont = false;\r
         }\r
 \r
         return tmp.substr(i);\r