Fix:Handle non-ascii characters in global search by not lowercasing in query #2187

This commit is contained in:
advplyr 2023-10-05 17:00:40 -05:00
parent bfe514b7d4
commit b447cf5c1c
4 changed files with 32 additions and 4 deletions

View file

@ -166,4 +166,27 @@ module.exports.getTitleIgnorePrefix = (title) => {
module.exports.getTitlePrefixAtEnd = (title) => {
let [sort, prefix] = getTitleParts(title)
return prefix ? `${sort}, ${prefix}` : title
}
/**
* to lower case for only ascii characters
* used to handle sqlite that doesnt support unicode lower
* @see https://github.com/advplyr/audiobookshelf/issues/2187
*
* @param {string} str
* @returns {string}
*/
module.exports.asciiOnlyToLowerCase = (str) => {
if (!str) return ''
let temp = ''
for (let chars of str) {
let value = chars.charCodeAt()
if (value >= 65 && value <= 90) {
temp += String.fromCharCode(value + 32)
} else {
temp += chars
}
}
return temp
}