mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
feature(util) rm isContainStrAtBegin
This commit is contained in:
parent
329df3e5c6
commit
57df106f0a
3 changed files with 3 additions and 33 deletions
|
|
@ -99,8 +99,8 @@
|
|||
*/
|
||||
function sendData(params, callback) {
|
||||
var p = params,
|
||||
isFS = Util.isContainStrAtBegin(p.name, CloudFunc.FS),
|
||||
isMD = Util.isContainStrAtBegin(p.name, '/markdown');
|
||||
isFS = /^\/fs/.test(p.name),
|
||||
isMD = /^\/markdown/.test(p.name);
|
||||
|
||||
if (isFS)
|
||||
onFS(params, callback);
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@
|
|||
|
||||
name = ponse.getPathName(request);
|
||||
isAuth = Util.strCmp(name, ['/auth', '/auth/github']);
|
||||
isFS = Util.strCmp(name, '/') || Util.isContainStrAtBegin(name, FS);
|
||||
isFS = RegExp('^/$|' + FS).test(name);
|
||||
|
||||
p = {
|
||||
request : request,
|
||||
|
|
|
|||
30
lib/util.js
30
lib/util.js
|
|
@ -269,36 +269,6 @@
|
|||
return is;
|
||||
};
|
||||
|
||||
/**
|
||||
* is pStr1 contains pStr2 at begin
|
||||
* @param pStr1
|
||||
* @param pStr2
|
||||
*/
|
||||
this.isContainStrAtBegin = function(pStr1, pStr2) {
|
||||
var i, n, length, subStr, ret,
|
||||
isStr1 = Util.type.string(pStr1),
|
||||
isArr2 = Util.type.array(pStr2);
|
||||
|
||||
if (isStr1)
|
||||
if (isArr2) {
|
||||
n = pStr2.length;
|
||||
|
||||
for(i = 0; i < n; i++) {
|
||||
ret = Util.isContainStrAtBegin(pStr1, pStr2[i]);
|
||||
|
||||
if (ret)
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
length = pStr2.length,
|
||||
subStr = pStr1.substring(0, length);
|
||||
|
||||
ret = subStr === pStr2;
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
/**
|
||||
* function log pArg if it's not empty
|
||||
* @param pArg
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue