Browse Source

make search term case insensitive

dev
xmcp 6 years ago
parent
commit
3ac560ffc6
  1. 4
      src/Common.js
  2. 2
      src/Flows.js

4
src/Common.js

@ -13,8 +13,8 @@ function escape_regex(string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
} }
export function build_highlight_re(txt,split) { export function build_highlight_re(txt,split,option='g') {
return txt ? new RegExp(`(${txt.split(split).filter((x)=>!!x).map(escape_regex).join('|')})`,'g') : /^$/g; return txt ? new RegExp(`(${txt.split(split).filter((x)=>!!x).map(escape_regex).join('|')})`,option) : /^$/g;
} }
export function ColoredSpan(props) { export function ColoredSpan(props) {

2
src/Flows.js

@ -516,7 +516,7 @@ class FlowItemRow extends PureComponent {
['nickname',NICKNAME_RE], ['nickname',NICKNAME_RE],
]; ];
if(this.props.search_param) 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 parts=split_text(this.state.info.text,hl_rules);
let quote_id=null; let quote_id=null;

Loading…
Cancel
Save