Skip to content

Commit 80197ef

Browse files
authored
Merge pull request #30 from launchdarkly/ag/check-flags-before-access
check `flags` exists before reading
2 parents 7f36b4a + ee58b46 commit 80197ef

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ function identify(user, hash, onDone) {
8787

8888
function variation(key, defaultValue) {
8989
var value;
90-
91-
if (flags.hasOwnProperty(key)) {
90+
91+
if (flags && flags.hasOwnProperty(key)) {
9292
value = flags[key] === null ? defaultValue : flags[key];
9393
} else {
9494
value = defaultValue;
@@ -101,6 +101,9 @@ function variation(key, defaultValue) {
101101

102102
function allFlags() {
103103
var results = {};
104+
105+
if (!flags) { return results; }
106+
104107
for (var key in flags) {
105108
if (flags.hasOwnProperty(key)) {
106109
results[key] = variation(key, null);

0 commit comments

Comments
 (0)