mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-20 18:18:56 +00:00
refactor(util) checkExtension: add lExtLength
This commit is contained in:
parent
a9be41801d
commit
6c5337fd4f
1 changed files with 6 additions and 5 deletions
11
lib/util.js
11
lib/util.js
|
|
@ -111,19 +111,20 @@ Util = exports || {};
|
|||
*/
|
||||
Util.checkExtension = function(pName, pExt) {
|
||||
var i, lExtNum, lExtSub,
|
||||
lRet = false,
|
||||
lLength = pName.length; /* длина имени*/
|
||||
lRet = false,
|
||||
lExtLenght = pExt && pExt.length,
|
||||
lLength = pName && pName.length; /* длина имени*/
|
||||
|
||||
/* если длина имени больше длинны расширения - имеет смысл продолжать
|
||||
*/
|
||||
if (Util.isString(pExt) && pName.length > pExt.length) {
|
||||
if (Util.isString(pExt) && lLength > lExtLenght) {
|
||||
lExtNum = pName.lastIndexOf(pExt), /* последнее вхождение расширения*/
|
||||
lExtSub = lLength - lExtNum; /* длина расширения*/
|
||||
|
||||
/* если pExt - расширение pName */
|
||||
lRet = lExtSub === pExt.length;
|
||||
lRet = lExtSub === lExtLength;
|
||||
|
||||
} else if (Util.isObject(pExt) && pExt.length)
|
||||
} else if (Util.isObject(pExt) && lExtLength)
|
||||
for(i = 0; i < pName.length; i++) {
|
||||
lRet = Util.checkExtension(pName, pExt[i]);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue