fix(parameter): adjust to filter before limit. (#13682)

* fix(parameter): adjust to filter before limit.

* fix(parameter): add test.

* fix
This commit is contained in:
Summer⛱
2023-11-03 13:46:04 +08:00
committed by GitHub
parent e8212ff05e
commit 90026020a8
2 changed files with 15 additions and 5 deletions

View File

@@ -149,11 +149,6 @@ module.exports = async (ctx, next) => {
ctx.state.data.item = await Promise.all(ctx.state.data.item.map(handleItem));
if (ctx.query) {
// limit
if (ctx.query.limit) {
ctx.state.data.item = ctx.state.data.item.slice(0, parseInt(ctx.query.limit));
}
// filter
const engine = config.feature.filter_regex_engine;
const makeRegex = (string) => {
@@ -251,6 +246,11 @@ module.exports = async (ctx, next) => {
});
}
// limit
if (ctx.query.limit) {
ctx.state.data.item = ctx.state.data.item.slice(0, parseInt(ctx.query.limit));
}
// telegram instant view
if (ctx.query.tgiv) {
ctx.state.data.item.map((item) => {