mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-03 00:06:46 +01:00
Remove asciiOnlyToLowerCase
This commit is contained in:
parent
e6db1495ab
commit
0adceaa3f0
@ -9,7 +9,6 @@ const libraryItemsBookFilters = require('../utils/queries/libraryItemsBookFilter
|
|||||||
const libraryItemFilters = require('../utils/queries/libraryItemFilters')
|
const libraryItemFilters = require('../utils/queries/libraryItemFilters')
|
||||||
const seriesFilters = require('../utils/queries/seriesFilters')
|
const seriesFilters = require('../utils/queries/seriesFilters')
|
||||||
const fileUtils = require('../utils/fileUtils')
|
const fileUtils = require('../utils/fileUtils')
|
||||||
const { asciiOnlyToLowerCase } = require('../utils/index')
|
|
||||||
const { createNewSortInstance } = require('../libs/fastSort')
|
const { createNewSortInstance } = require('../libs/fastSort')
|
||||||
const naturalSort = createNewSortInstance({
|
const naturalSort = createNewSortInstance({
|
||||||
comparer: new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' }).compare
|
comparer: new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' }).compare
|
||||||
@ -809,7 +808,7 @@ class LibraryController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const limit = req.query.limit || 12
|
const limit = req.query.limit || 12
|
||||||
const query = asciiOnlyToLowerCase(req.query.q.trim())
|
const query = req.query.q.trim()
|
||||||
|
|
||||||
const matches = await libraryItemFilters.search(req.user, req.library, query, limit)
|
const matches = await libraryItemFilters.search(req.user, req.library, query, limit)
|
||||||
res.json(matches)
|
res.json(matches)
|
||||||
|
@ -194,29 +194,6 @@ module.exports.getTitlePrefixAtEnd = (title) => {
|
|||||||
return prefix ? `${sort}, ${prefix}` : 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
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Escape string used in RegExp
|
* Escape string used in RegExp
|
||||||
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping
|
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping
|
||||||
|
Loading…
Reference in New Issue
Block a user