gi for search
This commit is contained in:
@@ -94,7 +94,7 @@ function is_audio(s) {
|
|||||||
export function build_highlight_re(
|
export function build_highlight_re(
|
||||||
txt,
|
txt,
|
||||||
split = ' ',
|
split = ' ',
|
||||||
option = 'g',
|
option = 'gi',
|
||||||
isRegex = false,
|
isRegex = false,
|
||||||
) {
|
) {
|
||||||
if (isRegex) {
|
if (isRegex) {
|
||||||
@@ -228,7 +228,7 @@ export class HighlightedMarkdown extends Component {
|
|||||||
try {
|
try {
|
||||||
search_re = new RegExp(
|
search_re = new RegExp(
|
||||||
`(${props.search_param.slice(1, -1)})`,
|
`(${props.search_param.slice(1, -1)})`,
|
||||||
'g',
|
'gi',
|
||||||
);
|
);
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
} else {
|
} else {
|
||||||
@@ -240,7 +240,7 @@ export class HighlightedMarkdown extends Component {
|
|||||||
`(${search_kws
|
`(${search_kws
|
||||||
.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
|
.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
|
||||||
.join('|')})`,
|
.join('|')})`,
|
||||||
'g',
|
'gi',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
src/Flows.js
12
src/Flows.js
@@ -1649,7 +1649,10 @@ class SubFlow extends PureComponent {
|
|||||||
let regex_search = /.+/;
|
let regex_search = /.+/;
|
||||||
if (use_regex) {
|
if (use_regex) {
|
||||||
try {
|
try {
|
||||||
regex_search = new RegExp(this.state.search_param.slice(1, -1));
|
regex_search = new RegExp(
|
||||||
|
this.state.search_param.slice(1, -1),
|
||||||
|
'i',
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
alert(`请检查正则表达式合法性!\n${e}`);
|
alert(`请检查正则表达式合法性!\n${e}`);
|
||||||
regex_search = /.+/;
|
regex_search = /.+/;
|
||||||
@@ -1673,10 +1676,11 @@ class SubFlow extends PureComponent {
|
|||||||
? json.data
|
? json.data
|
||||||
: !use_regex
|
: !use_regex
|
||||||
? json.data.filter((post) => {
|
? json.data.filter((post) => {
|
||||||
|
const search_text = get_search_text(post).toLowerCase();
|
||||||
return this.state.search_param
|
return this.state.search_param
|
||||||
.split(' ')
|
.split(' ')
|
||||||
.every((keyword) =>
|
.every((keyword) =>
|
||||||
get_search_text(post).includes(keyword),
|
search_text.includes(keyword.toLowerCase()),
|
||||||
);
|
);
|
||||||
}) // Not using regex
|
}) // Not using regex
|
||||||
: json.data.filter(
|
: json.data.filter(
|
||||||
@@ -1730,10 +1734,12 @@ class SubFlow extends PureComponent {
|
|||||||
? json.data
|
? json.data
|
||||||
: !use_regex
|
: !use_regex
|
||||||
? json.data.filter((post) => {
|
? json.data.filter((post) => {
|
||||||
|
const search_text =
|
||||||
|
get_search_text(post).toLowerCase();
|
||||||
return this.state.search_param
|
return this.state.search_param
|
||||||
.split(' ')
|
.split(' ')
|
||||||
.every((keyword) =>
|
.every((keyword) =>
|
||||||
get_search_text(post).includes(keyword),
|
search_text.includes(keyword.toLowerCase()),
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
: json.data.filter(
|
: json.data.filter(
|
||||||
|
|||||||
Reference in New Issue
Block a user