From b6825498a173d8f63a58546e65c5043c746030ec Mon Sep 17 00:00:00 2001 From: lqqyt2423 <974923609@qq.com> Date: Sun, 26 Sep 2021 16:17:57 +0800 Subject: [PATCH] addon web: filter support regexp --- addon/web/client/src/flow.ts | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/addon/web/client/src/flow.ts b/addon/web/client/src/flow.ts index fa63d31..f679e72 100644 --- a/addon/web/client/src/flow.ts +++ b/addon/web/client/src/flow.ts @@ -19,9 +19,26 @@ export class FlowManager { } showList() { - if (!this.filterText) return this.items + let text = this.filterText + if (text) text = text.trim() + if (!text) return this.items + + // regexp + if (text.startsWith('/') && text.endsWith('/')) { + text = text.slice(1, text.length - 1).trim() + if (!text) return this.items + try { + const reg = new RegExp(text) + return this.items.filter(item => { + return reg.test(item.request.url) + }) + } catch (err) { + return this.items + } + } + return this.items.filter(item => { - return item.request.url.includes(this.filterText) + return item.request.url.includes(text) }) }