Skip to content

Commit

Permalink
Добавлен костыль - неверная кодировка от koreader при поиске в opds
Browse files Browse the repository at this point in the history
  • Loading branch information
bookpauk committed Mar 2, 2023
1 parent 371d564 commit 06300e3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion server/core/opds/SearchPage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const BasePage = require('./BasePage');
const utils = require('../utils');
const iconv = require('iconv-lite');

class SearchPage extends BasePage {
constructor(config) {
Expand Down Expand Up @@ -28,7 +29,14 @@ class SearchPage extends BasePage {

const limit = 100;
const offset = (page - 1)*limit;
const queryRes = await this.webWorker.search(from, {[from]: query.term, genre: query.genre, del: '0', offset, limit});

const searchQuery = {[from]: query.term, genre: query.genre, del: '0', offset, limit};
let queryRes = await this.webWorker.search(from, searchQuery);

if (queryRes.totalFound === 0) { // не нашли ничего, проверим, может term в кодировке ISO-8859-1 (баг koreader)
searchQuery[from] = iconv.encode(query.term, 'ISO-8859-1').toString();
queryRes = await this.webWorker.search(from, searchQuery);
}

const found = queryRes.found;

Expand Down

0 comments on commit 06300e3

Please sign in to comment.