From b800e12898cea3675e43d04de4d1e7fa95c57044 Mon Sep 17 00:00:00 2001 From: IntermittentlyRupert <4526480+IntermittentlyRupert@users.noreply.github.com> Date: Sun, 12 Sep 2021 19:39:34 +1000 Subject: [PATCH] fix(catmanga): SearchRequest is now immutable (#9) --- src/CatManga/CatManga.ts | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/CatManga/CatManga.ts b/src/CatManga/CatManga.ts index cc39993..c965a7c 100644 --- a/src/CatManga/CatManga.ts +++ b/src/CatManga/CatManga.ts @@ -15,7 +15,7 @@ const BASE = "https://catmanga.org" export const CatMangaInfo: SourceInfo = { icon: "icon.png", - version: "1.2.9", + version: "1.2.10", name: "CatManga", author: "PythonCoderAS", authorWebsite: "https://github.com/PythonCoderAS", @@ -101,18 +101,15 @@ export class CatManga extends Source { async searchRequest(query: SearchRequest, metadata: any): Promise { // TODO: Wait for search to be implemented on the website. const results = (await this.getWebsiteMangaDirectory(null)).results; + + let data: MangaTile[]; if (query.title){ - query.title = query.title.replace(/\+/g, " ").trim(); - } - const data: MangaTile[] = []; - for (let i = 0; i < results.length; i++) { - const key = results[i]; - if (query.title) { - if ((key.title.text || "").toLowerCase().includes((query.title.toLowerCase()))) { - data.push(key); - } - } + const filterTitle = query.title.replace(/\+/g, " ").trim().toLowerCase(); + data = results.filter((key) => (key.title.text || "").toLowerCase().includes(filterTitle)) + } else { + data = results; } + console.log(data.length) return createPagedResults({ results: data