Skip to content
Permalink
Browse files Browse the repository at this point in the history
fix: use re2, thank @Rongronggg9
  • Loading branch information
DIYgod committed Jun 21, 2022
1 parent 041cfc3 commit 5c41774
Show file tree
Hide file tree
Showing 3 changed files with 305 additions and 18 deletions.
5 changes: 3 additions & 2 deletions lib/middleware/parameter.js
Expand Up @@ -3,6 +3,7 @@ const cheerio = require('cheerio');
const { simplecc } = require('simplecc-wasm');
const got = require('@/utils/got');
const config = require('@/config').value;
const RE2 = require('re2');

let mercury_parser;

Expand Down Expand Up @@ -152,9 +153,9 @@ module.exports = async (ctx, next) => {
const makeRegex = (string) => {
// default: case_senstivie = true
if (ctx.query.filter_case_sensitive === 'false') {
return new RegExp(string, 'i');
return new RE2(string, 'i');
} else {
return new RegExp(string);
return new RE2(string);
}
};

Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -123,6 +123,7 @@
"puppeteer-extra-plugin-stealth": "2.10.0",
"query-string": "7.1.1",
"rand-user-agent": "1.0.68",
"re2": "1.17.7",
"require-all": "3.0.0",
"rss-parser": "3.12.0",
"showdown": "2.1.0",
Expand Down

0 comments on commit 5c41774

Please sign in to comment.