Fix:Library collapsed series to respect ignore prefixes setting #866

This commit is contained in:
advplyr 2022-07-30 16:18:26 -05:00
parent 377ae7ab19
commit 06b8d1194c
6 changed files with 28 additions and 16 deletions

View file

@ -135,4 +135,16 @@ module.exports.cleanStringForSearch = (str) => {
if (!str) return ''
// Remove ' . ` " ,
return str.toLowerCase().replace(/[\'\.\`\",]/g, '').trim()
}
module.exports.getTitleIgnorePrefix = (title) => {
if (!title) return ''
var prefixesToIgnore = global.ServerSettings.sortingPrefixes || []
for (const prefix of prefixesToIgnore) {
// e.g. for prefix "the". If title is "The Book" return "Book, The"
if (title.toLowerCase().startsWith(`${prefix} `)) {
return title.substr(prefix.length + 1) + `, ${prefix.substr(0, 1).toUpperCase() + prefix.substr(1)}`
}
}
return title
}