Private widget options API

This commit is contained in:
Michael Shamoon committed 2022-10-11 12:16:18 -07:00
1 parent 8e2ff61f1c
commit 7c39cd8960
3 files changed
+39 -4

No files matched your search

+13
View File
@@ -34,3 +34,16 @@ export function getSettings() {
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;
}