提交 c0d8a9db 编写于 作者: J Jason Park

Improve keyword search

上级 68a1629d
......@@ -62,7 +62,11 @@ class Navigator extends React.Component {
testQuery(value) {
const { query } = this.state;
return new RegExp(query, 'i').test(value);
const refine = string => string.replace(/-/g, ' ').replace(/[^\w ]/g, '');
const refinedQuery = refine(query);
const refinedValue = refine(value);
return new RegExp(`(^| )${refinedQuery}`, 'i').test(refinedValue) ||
new RegExp(refinedQuery, 'i').test(refinedValue.split(' ').map(v => v && v[0]).join(''));
}
render() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册