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

fix(catmanga): SearchRequest is now immutable (#9) #10

Merged
merged 1 commit into from
Sep 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions src/CatManga/CatManga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -101,18 +101,15 @@ export class CatManga extends Source {
async searchRequest(query: SearchRequest, metadata: any): Promise<PagedResults> {
// 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
Expand Down