Skip to content

Commit

Permalink
Fix:Crash when author is set without a name #1934
Browse files Browse the repository at this point in the history
  • Loading branch information
advplyr committed Jul 19, 2023
1 parent 24b9ac6 commit c2793fe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion server/controllers/AuthorController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion server/objects/entities/Author.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c2793fe

Please sign in to comment.