mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-06-24 09:49:24 +02:00
New filters using base64 strings, keyword filter
This commit is contained in:
parent
af05e78cdf
commit
d2a2f3ff6a
13 changed files with 152 additions and 79 deletions
|
@ -57,6 +57,11 @@ Vue.prototype.$normalToSnake = (normie) => {
|
|||
.join('_')
|
||||
}
|
||||
|
||||
const encode = (text) => encodeURIComponent(Buffer.from(text).toString('base64'))
|
||||
Vue.prototype.$encode = encode
|
||||
const decode = (text) => Buffer.from(decodeURIComponent(text), 'base64').toString()
|
||||
Vue.prototype.$decode = decode
|
||||
|
||||
const availableChars = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
|
||||
const getCharCode = (char) => availableChars.indexOf(char)
|
||||
const getCharFromCode = (code) => availableChars[Number(code)] || -1
|
||||
|
@ -109,21 +114,6 @@ Vue.prototype.$codeToString = (code) => {
|
|||
return finalform
|
||||
}
|
||||
|
||||
function cleanString(str, availableChars) {
|
||||
var _str = str.normalize('NFD').replace(/[\u0300-\u036f]/g, "")
|
||||
var cleaned = ''
|
||||
for (let i = 0; i < _str.length; i++) {
|
||||
cleaned += availableChars.indexOf(str[i]) < 0 ? '' : str[i]
|
||||
}
|
||||
return cleaned
|
||||
}
|
||||
|
||||
export const cleanFilterString = (str) => {
|
||||
var _str = str.toLowerCase().replace(/ /g, '_')
|
||||
_str = cleanString(_str, "0123456789abcdefghijklmnopqrstuvwxyz")
|
||||
return _str
|
||||
}
|
||||
|
||||
function loadImageBlob(uri) {
|
||||
return new Promise((resolve) => {
|
||||
const img = document.createElement('img')
|
||||
|
@ -204,3 +194,8 @@ Vue.prototype.$sanitizeFilename = (input, replacement = '') => {
|
|||
.replace(windowsTrailingRe, replacement);
|
||||
return sanitized
|
||||
}
|
||||
|
||||
export {
|
||||
encode,
|
||||
decode
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue