mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-14 01:08:22 +02:00
when checking if series/author is alread in DB, use case insensitive match only for ASCII names
This commit is contained in:
@ -53,14 +53,26 @@ class Author extends Model {
|
||||
* @returns {Promise<Author>}
|
||||
*/
|
||||
static async getByNameAndLibrary(authorName, libraryId) {
|
||||
return this.findOne({
|
||||
where: [
|
||||
where(fn('lower', col('name')), authorName.toLowerCase()),
|
||||
{
|
||||
libraryId
|
||||
const containsOnlyASCII = /^[\u0000-\u007f]*$/.test(authorName)
|
||||
|
||||
// SQLite does not support lower with non-Unicode chars
|
||||
if (!containsOnlyASCII) {
|
||||
return this.findOne({
|
||||
where: {
|
||||
name: authorName,
|
||||
libraryId: libraryId
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
} else {
|
||||
return this.findOne({
|
||||
where: [
|
||||
where(fn('lower', col('name')), authorName.toLowerCase()),
|
||||
{
|
||||
libraryId
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user