From 76970da3554161582fb1fc8e3af459f3c5371a4d Mon Sep 17 00:00:00 2001 From: Jay Date: Tue, 21 Aug 2018 15:09:44 +0800 Subject: [PATCH 1/3] fix regex bug --- libs/line-message/commands/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/line-message/commands/index.js b/libs/line-message/commands/index.js index 5064721..cd991c7 100644 --- a/libs/line-message/commands/index.js +++ b/libs/line-message/commands/index.js @@ -73,6 +73,7 @@ const parseCMD = async (text = '', source = {}) => { let txt = '' console.log('obj ::: ', obj) for (let i of obj) { + i.key = i.key.replace(/(\+|\[|\]|\*|\$|\^|\(|\))/g, '\\$1') txt += (txt.length > 0 ? '|' : '') + i.key } regex = new RegExp(`^(${txt})$`) From 3258f71340e25a9a488429ad0465054bbc6f1c93 Mon Sep 17 00:00:00 2001 From: Jay Date: Tue, 21 Aug 2018 15:12:47 +0800 Subject: [PATCH 2/3] modify --- libs/line-message/commands/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/line-message/commands/index.js b/libs/line-message/commands/index.js index cd991c7..58e7340 100644 --- a/libs/line-message/commands/index.js +++ b/libs/line-message/commands/index.js @@ -73,8 +73,8 @@ const parseCMD = async (text = '', source = {}) => { let txt = '' console.log('obj ::: ', obj) for (let i of obj) { - i.key = i.key.replace(/(\+|\[|\]|\*|\$|\^|\(|\))/g, '\\$1') - txt += (txt.length > 0 ? '|' : '') + i.key + let key = i.key.replace(/(\+|\[|\]|\*|\$|\^|\(|\))/g, '\\$1') + txt += (txt.length > 0 ? '|' : '') + key } regex = new RegExp(`^(${txt})$`) console.log(regex) From eea74a7239f497308ca94acc16fbd209fcc36b79 Mon Sep 17 00:00:00 2001 From: Jay Date: Tue, 21 Aug 2018 22:49:24 +0800 Subject: [PATCH 3/3] add logout api --- route/api/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/route/api/index.js b/route/api/index.js index 1e96956..f41bd1b 100644 --- a/route/api/index.js +++ b/route/api/index.js @@ -55,6 +55,11 @@ r.post('/login', koaBody(), async (c, n) => { c.obj = resObject('Success') }) +r.post('/logout', async (c, n) => { + c.session = null + c.obj = resObject('Success') +}) + r.get('/session', checkSession, async (c, n) => { c.obj = resObject('Success', { user: c.state.loginUser