Refactor info widget sanitizing / privateOptions

This commit is contained in:
Michael Shamoon 2022-10-11 20:26:07 -07:00
parent dced918804
commit 48a09e5a99
6 changed files with 89 additions and 53 deletions

View file

@ -33,17 +33,4 @@ export function getSettings() {
const settingsYaml = join(process.cwd(), "config", "settings.yaml");
const fileContents = readFileSync(settingsYaml, "utf8");
return yaml.load(fileContents);
}
export function sanitizePrivateOptions(options, privateOnly = false) {
const privateOptions = ["url", "username", "password", "key"];
const sanitizedOptions = {};
Object.keys(options).forEach((key) => {
if (!privateOnly && !privateOptions.includes(key)) {
sanitizedOptions[key] = options[key];
} else if (privateOnly && privateOptions.includes(key)) {
sanitizedOptions[key] = options[key];
}
});
return sanitizedOptions;
}