Skip to content
This repository was archived by the owner on Nov 20, 2021. It is now read-only.

Commit 30cce1d

Browse files
Merge pull request #10 from IntermittentlyRupert/fix/9-catmanga-search
fix(catmanga): SearchRequest is now immutable (#9)
2 parents eb45773 + b800e12 commit 30cce1d

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

‎src/CatManga/CatManga.ts

+8-11
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const BASE = "https://catmanga.org"
1515

1616
export const CatMangaInfo: SourceInfo = {
1717
icon: "icon.png",
18-
version: "1.2.9",
18+
version: "1.2.10",
1919
name: "CatManga",
2020
author: "PythonCoderAS",
2121
authorWebsite: "https://github.com/PythonCoderAS",
@@ -101,18 +101,15 @@ export class CatManga extends Source {
101101
async searchRequest(query: SearchRequest, metadata: any): Promise<PagedResults> {
102102
// TODO: Wait for search to be implemented on the website.
103103
const results = (await this.getWebsiteMangaDirectory(null)).results;
104+
105+
let data: MangaTile[];
104106
if (query.title){
105-
query.title = query.title.replace(/\+/g, " ").trim();
106-
}
107-
const data: MangaTile[] = [];
108-
for (let i = 0; i < results.length; i++) {
109-
const key = results[i];
110-
if (query.title) {
111-
if ((key.title.text || "").toLowerCase().includes((query.title.toLowerCase()))) {
112-
data.push(key);
113-
}
114-
}
107+
const filterTitle = query.title.replace(/\+/g, " ").trim().toLowerCase();
108+
data = results.filter((key) => (key.title.text || "").toLowerCase().includes(filterTitle))
109+
} else {
110+
data = results;
115111
}
112+
116113
console.log(data.length)
117114
return createPagedResults({
118115
results: data

0 commit comments

Comments
 (0)