mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-10 01:15:06 +02:00
Update:Author names ignore periods when checking for existing authors #993
This commit is contained in:
parent
ae4ac392c6
commit
be592a04d0
2 changed files with 11 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
||||||
const Logger = require('../../Logger')
|
const Logger = require('../../Logger')
|
||||||
const { getId } = require('../../utils/index')
|
const { getId } = require('../../utils/index')
|
||||||
|
const { checkNamesAreEqual } = require('../../utils/parsers/parseNameString')
|
||||||
|
|
||||||
class Author {
|
class Author {
|
||||||
constructor(author) {
|
constructor(author) {
|
||||||
|
@ -86,7 +87,7 @@ class Author {
|
||||||
Logger.error(`[Author] Author name is null (${this.id})`)
|
Logger.error(`[Author] Author name is null (${this.id})`)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return this.name.toLowerCase() == name.toLowerCase().trim()
|
return checkNamesAreEqual(this.name, name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.exports = Author
|
module.exports = Author
|
|
@ -91,4 +91,13 @@ module.exports.parse = (nameString) => {
|
||||||
nameLF: lastFirst, // String of comma separated last, first
|
nameLF: lastFirst, // String of comma separated last, first
|
||||||
names: namesArray // Array of first last
|
names: namesArray // Array of first last
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.checkNamesAreEqual = (name1, name2) => {
|
||||||
|
if (!name1 || !name2) return false
|
||||||
|
|
||||||
|
// e.g. John H. Smith will be equal to John H Smith
|
||||||
|
name1 = String(name1).toLowerCase().trim().replace(/\./g, '')
|
||||||
|
name2 = String(name2).toLowerCase().trim().replace(/\./g, '')
|
||||||
|
return name1 === name2
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue