mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-02-28 21:19:42 +00:00
feat: implement duplicate title normalized filter
This commit is contained in:
parent
aa85106681
commit
ead215e777
13 changed files with 276 additions and 1 deletions
|
|
@ -191,6 +191,18 @@ module.exports.getTitleIgnorePrefix = (title) => {
|
|||
return getTitleParts(title)[0]
|
||||
}
|
||||
|
||||
/**
|
||||
* Get normalized title to use for grouping duplicates
|
||||
* Removes non-alphabetic characters (numbers, punctuation, spaces)
|
||||
* @param {string} title
|
||||
* @returns {string}
|
||||
*/
|
||||
module.exports.getNormalizedTitle = (title) => {
|
||||
if (!title) return ''
|
||||
const sortTitle = getTitleParts(title)[0] || title
|
||||
return sortTitle.toLowerCase().replace(/[^\p{L}]/gu, '')
|
||||
}
|
||||
|
||||
/**
|
||||
* Put sorting prefix at the end of title
|
||||
* @example "The Good Book" => "Good Book, The"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue