New filters using base64 strings, keyword filter

This commit is contained in:
Mark Cooper 2021-09-05 13:21:02 -05:00
parent af05e78cdf
commit d2a2f3ff6a
13 changed files with 152 additions and 79 deletions

View file

@ -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
}