From 3ac560ffc61804ba4e1fc199d254cd1f4d2632c5 Mon Sep 17 00:00:00 2001 From: xmcp Date: Mon, 10 Feb 2020 01:49:12 +0800 Subject: [PATCH] make search term case insensitive --- src/Common.js | 4 ++-- src/Flows.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Common.js b/src/Common.js index e06757dd..81171d8e 100644 --- a/src/Common.js +++ b/src/Common.js @@ -13,8 +13,8 @@ function escape_regex(string) { return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string } -export function build_highlight_re(txt,split) { - return txt ? new RegExp(`(${txt.split(split).filter((x)=>!!x).map(escape_regex).join('|')})`,'g') : /^$/g; +export function build_highlight_re(txt,split,option='g') { + return txt ? new RegExp(`(${txt.split(split).filter((x)=>!!x).map(escape_regex).join('|')})`,option) : /^$/g; } export function ColoredSpan(props) { diff --git a/src/Flows.js b/src/Flows.js index 0c0db45f..3d093cf9 100644 --- a/src/Flows.js +++ b/src/Flows.js @@ -516,7 +516,7 @@ class FlowItemRow extends PureComponent { ['nickname',NICKNAME_RE], ]; if(this.props.search_param) - hl_rules.push(['search',build_highlight_re(this.props.search_param,' ')]); + hl_rules.push(['search',build_highlight_re(this.props.search_param,' ','gi')]); let parts=split_text(this.state.info.text,hl_rules); let quote_id=null;