mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-19 17:35:34 +00:00
fix(util) strCmp: indexOf && length
This commit is contained in:
parent
4a2cec4625
commit
c3db0876b1
1 changed files with 11 additions and 5 deletions
16
lib/util.js
16
lib/util.js
|
|
@ -270,7 +270,7 @@
|
|||
* @param {String, Array} str2
|
||||
*/
|
||||
this.strCmp = function(str1, str2) {
|
||||
var ret,
|
||||
var length1, length2, isEqual,
|
||||
isStr = Util.isString(str1),
|
||||
type = Util.getType(str2);
|
||||
|
||||
|
|
@ -278,18 +278,24 @@
|
|||
switch(type) {
|
||||
case 'array':
|
||||
str2.some(function(str) {
|
||||
ret = Util.strCmp(str1, str);
|
||||
isEqual = Util.strCmp(str1, str);
|
||||
|
||||
return ret;
|
||||
return isEqual;
|
||||
});
|
||||
break;
|
||||
|
||||
case 'string':
|
||||
ret = !str1.indexOf(str2);
|
||||
length1 = str1.length;
|
||||
length2 = str2.length;
|
||||
isEqual = length1 === length2;
|
||||
|
||||
if (isEqual)
|
||||
isEqual = !str1.indexOf(str2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return isEqual;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue