mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat(core): regex engine config (#10013)
This commit is contained in:
@@ -152,10 +152,25 @@ module.exports = async (ctx, next) => {
|
||||
// filter
|
||||
const makeRegex = (string) => {
|
||||
// default: case_senstivie = true
|
||||
const engine = config.feature.filter_regex_engine;
|
||||
if (ctx.query.filter_case_sensitive === 'false') {
|
||||
return new RE2(string, 'i');
|
||||
switch (engine) {
|
||||
case 'regexp':
|
||||
return new RegExp(string, 'i');
|
||||
case 're':
|
||||
return new RE2(string, 'i');
|
||||
default:
|
||||
throw Error(`Invalid Engine Value: ${engine}, please check your config.`);
|
||||
}
|
||||
} else {
|
||||
return new RE2(string);
|
||||
switch (engine) {
|
||||
case 'regexp':
|
||||
return new RegExp(string);
|
||||
case 're':
|
||||
return new RE2(string);
|
||||
default:
|
||||
throw Error(`Invalid Engine Value: ${engine}, please check your config.`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user