Private widget options API
This commit is contained in:
1 parent
8e2ff61f1c
commit
7c39cd8960
3 files changed
+39
-4
No files matched your search
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user