thaldrin/src/utils/clean.ts

25 lines
653 B
TypeScript
Raw Normal View History

import config from '../../config'
import replace from './replace'
let SensitiveStrings = [
2021-09-11 11:38:36 +00:00
config.discord?.token,
config.supabase.key,
config.supabase.url,
config.apis.sheri,
config.apis.yiffrest,
2021-07-08 11:59:37 +00:00
config.trello.key,
config.trello.token,
].flat(Infinity)
export default function clean(content: any) {
let type = content
if (typeof type === 'object') {
content = JSON.stringify(content)
}
let regex = new RegExp(`(${SensitiveStrings.join("|")})`, "gi")
content = replace(regex, "*snip*", content)
if (typeof type === 'object') {
content = JSON.parse(content)
}
return content
}