From 57df106f0ae06fd285e4cf809ace17e0682c96a3 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 27 Oct 2014 11:50:31 -0400 Subject: [PATCH] feature(util) rm isContainStrAtBegin --- lib/server/rest.js | 4 ++-- lib/server/route.js | 2 +- lib/util.js | 30 ------------------------------ 3 files changed, 3 insertions(+), 33 deletions(-) diff --git a/lib/server/rest.js b/lib/server/rest.js index 9a92406e..18557ddd 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -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); diff --git a/lib/server/route.js b/lib/server/route.js index f7a1c164..a6eabd98 100644 --- a/lib/server/route.js +++ b/lib/server/route.js @@ -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, diff --git a/lib/util.js b/lib/util.js index bcfe8ada..bbd7557b 100644 --- a/lib/util.js +++ b/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