From c2793fe29b96707908524406742c02c3e40634f7 Mon Sep 17 00:00:00 2001 From: advplyr Date: Wed, 19 Jul 2023 17:13:57 -0500 Subject: [PATCH] Fix:Crash when author is set without a name #1934 --- server/controllers/AuthorController.js | 2 +- server/objects/entities/Author.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/server/controllers/AuthorController.js b/server/controllers/AuthorController.js index c8bda43b..9c8fc7bd 100644 --- a/server/controllers/AuthorController.js +++ b/server/controllers/AuthorController.js @@ -165,7 +165,7 @@ class AuthorController { var q = (req.query.q || '').toLowerCase() if (!q) return res.json([]) var limit = (req.query.limit && !isNaN(req.query.limit)) ? Number(req.query.limit) : 25 - var authors = Database.authors.filter(au => au.name.toLowerCase().includes(q)) + var authors = Database.authors.filter(au => au.name?.toLowerCase().includes(q)) authors = authors.slice(0, limit) res.json({ results: authors diff --git a/server/objects/entities/Author.js b/server/objects/entities/Author.js index 2a0ffa8b..6ad1d303 100644 --- a/server/objects/entities/Author.js +++ b/server/objects/entities/Author.js @@ -57,7 +57,10 @@ class Author { setData(data, libraryId) { this.id = uuidv4() - this.name = data.name + if (!data.name) { + Logger.error(`[Author] setData: Setting author data without a name`, data) + } + this.name = data.name || '' this.description = data.description || null this.asin = data.asin || null this.imagePath = data.imagePath || null