mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-08 00:08:14 +01:00
Update:Author names ignore periods when checking for existing authors #993
This commit is contained in:
parent
ae4ac392c6
commit
be592a04d0
@ -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
|
@ -92,3 +92,12 @@ module.exports.parse = (nameString) => {
|
|||||||
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…
Reference in New Issue
Block a user