From 2f8a90c21a4eea257dbdbb85e4cec6a5e76794ab Mon Sep 17 00:00:00 2001 From: ISO-B <3048685+ISO-B@users.noreply.github.com> Date: Tue, 4 Jan 2022 12:20:28 +0200 Subject: [PATCH] Added isbn search Search now also searches books using isbn. ISBN match has to be exact to prevent isbn matches to flood results. --- server/objects/Book.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/objects/Book.js b/server/objects/Book.js index 34109475..f8661eeb 100644 --- a/server/objects/Book.js +++ b/server/objects/Book.js @@ -278,8 +278,12 @@ class Book { // var authorMatch = this._author.toLowerCase().includes(search) var seriesMatch = this._series.toLowerCase().includes(search) + + // ISBN match has to be exact to prevent isbn matches to flood results. Remove dashes since isbn might have those + var isbnMatch = this.isbn.toLowerCase().replaceAll('-', '') === search.replaceAll('-', '') + + var bookMatchKey = titleMatch ? 'title' : subtitleMatch ? 'subtitle' : authorsMatched.length ? 'authorFL' : seriesMatch ? 'series' : isbnMatch ? 'isbn' : false - var bookMatchKey = titleMatch ? 'title' : subtitleMatch ? 'subtitle' : authorsMatched.length ? 'authorFL' : seriesMatch ? 'series' : false var bookMatchText = bookMatchKey ? this[bookMatchKey] : '' return { book: bookMatchKey,