-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Treat empty strings as an empty set of contacts (#10)
* entity contacts should be disregarded when check contacts are present * treat empty string values as no contacts
- Loading branch information
Cameron Johnston
authored
Jun 27, 2019
1 parent
313e4d6
commit a414eb9
Showing
2 changed files
with
30 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,22 @@ | ||
function no_contacts(event) { | ||
var check_contacts = []; | ||
var entity_contacts = []; | ||
|
||
if (event.hasOwnProperty("check") && event.check.hasOwnProperty("labels") && event.check.labels.hasOwnProperty("contacts")) { | ||
return false; | ||
check_contacts = event.check.labels.contacts.split(","); | ||
// filter out any elements which do not contain at least one non-whitespace character | ||
check_contacts = check_contacts.filter(function(entry) { return /\S/.test(entry); }); | ||
} | ||
else if (event.hasOwnProperty("entity") && event.entity.hasOwnProperty("labels") && event.entity.labels.hasOwnProperty("contacts")) { | ||
return false; | ||
} else { | ||
|
||
if (event.hasOwnProperty("entity") && event.entity.hasOwnProperty("labels") && event.entity.labels.hasOwnProperty("contacts")) { | ||
entity_contacts = event.entity.labels.contacts.split(","); | ||
// filter out any elements which do not contain at least one non-whitespace character | ||
entity_contacts = entity_contacts.filter(function(entry) { return /\S/.test(entry); }); | ||
} | ||
|
||
if (check_contacts.length == 0 && entity_contacts.length == 0) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters