diff --git a/app.js b/app.js index 07638867eb..a3b0b43ce3 100644 --- a/app.js +++ b/app.js @@ -257,12 +257,10 @@ if (config.protocol === 'io') { * Otherwise, an empty string will be returned. */ toId = function(text) { - if (typeof text === 'number') text = ''+text; if (text && text.id) text = text.id; else if (text && text.userid) text = text.userid; - text = string(text); - if (typeof text !== 'string') return ''; //??? - return text.toLowerCase().replace(/[^a-z0-9]+/g, ''); + + return string(text).toLowerCase().replace(/[^a-z0-9]+/g, ''); }; toUserid = toId; diff --git a/battles.js b/battles.js index d561a89f5c..a9a09cce7f 100644 --- a/battles.js +++ b/battles.js @@ -30,11 +30,10 @@ if (config.crashguard) { * Otherwise, an empty string will be returned. */ toId = function(text) { - if (typeof text === 'number') text = ''+text; if (text && text.id) text = text.id; - text = string(text); - if (typeof text !== 'string') return ''; //??? - return text.toLowerCase().replace(/[^a-z0-9]+/g, ''); + else if (text && text.userid) text = text.userid; + + return string(text).toLowerCase().replace(/[^a-z0-9]+/g, ''); }; toUserid = toId;