Refactor info widget sanitizing / privateOptions

This commit is contained in:
Michael Shamoon committed 2022-10-12 01:53:57 -07:00
1 parent dced918804
commit 48a09e5a99
6 files changed
+89 -53

No files matched your search

-13
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;
}