From 2068ef7053156840c4375ea76f2b2ed08f080e1c Mon Sep 17 00:00:00 2001 From: hanhh <18330117883@163.com> Date: Wed, 29 Sep 2021 23:15:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=B1=BB=E5=9E=8B=E6=A3=80?= =?UTF-8?q?=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/loaders/express.ts | 7 +++---- shell/task.sh | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/back/loaders/express.ts b/back/loaders/express.ts index b04daeb9..b31ce871 100644 --- a/back/loaders/express.ts +++ b/back/loaders/express.ts @@ -45,11 +45,10 @@ export default ({ app }: { app: Application }) => { if (req.path.startsWith('/open/')) { const openService = Container.get(OpenService); const doc = await openService.findTokenByValue(headerToken); - if (doc && doc.tokens.length > 0) { + if (doc && doc.tokens && doc.tokens.length > 0) { const currentToken = doc.tokens.find((x) => x.value === headerToken); - const key = - req.path.match(/\/open\/([a-z]+)\/*/) && - req.path.match(/\/open\/([a-z]+)\/*/)[1]; + const keyMatch = req.path.match(/\/open\/([a-z]+)\/*/); + const key = keyMatch && keyMatch[1]; if ( doc.scopes.includes(key as any) && currentToken && diff --git a/shell/task.sh b/shell/task.sh index f0b8967b..c86302f0 100755 --- a/shell/task.sh +++ b/shell/task.sh @@ -169,7 +169,7 @@ run_designated() { local env_param="$2" local num_param=$(echo "$3" | perl -pe "s|.*$2 (.*)|\1|") if [[ ! $env_param ]] || [[ ! $num_param ]]; then - echo -e "\n 缺少单独运行的参数 task xxx.js single Test 1" + echo -e "\n 缺少单独运行的参数 task xxx.js desi Test 1 3" exit 1 fi