diff --git a/server/objects/entities/Author.js b/server/objects/entities/Author.js index ebbe2b76..2c7f54fd 100644 --- a/server/objects/entities/Author.js +++ b/server/objects/entities/Author.js @@ -1,3 +1,4 @@ +const Logger = require('../../Logger') const { getId } = require('../../utils/index') class Author { @@ -19,7 +20,7 @@ class Author { construct(author) { this.id = author.id this.asin = author.asin - this.name = author.name + this.name = author.name || '' this.description = author.description || null this.imagePath = author.imagePath this.relImagePath = author.relImagePath @@ -81,6 +82,10 @@ class Author { checkNameEquals(name) { if (!name) return false + if (this.name === null) { + Logger.error(`[Author] Author name is null (${this.id})`) + return false + } return this.name.toLowerCase() == name.toLowerCase().trim() } } diff --git a/server/utils/parseNameString.js b/server/utils/parseNameString.js index 18212e30..068470a1 100644 --- a/server/utils/parseNameString.js +++ b/server/utils/parseNameString.js @@ -79,6 +79,9 @@ module.exports.parse = (nameString) => { } } + // Filter out names that have no first and last + names = names.filter(n => n.first_name || n.last_name) + var namesArray = names.map(a => a.first_name ? `${a.first_name} ${a.last_name}` : a.last_name) var firstLast = names.length ? namesArray.join(', ') : '' var lastFirst = names.length ? names.map(a => a.first_name ? `${a.last_name}, ${a.first_name}` : a.last_name).join(', ') : ''