Skip to content

Commit

Permalink
Splat validation.
Browse files Browse the repository at this point in the history
Check to ensure the splat contains only strings before trying to use
them to access an objects properties. Return check if module.exports is
not available.
  • Loading branch information
tommcgurl committed Feb 6, 2015
1 parent 005b22e commit 120f7e1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions check.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ check =
# return if the first argument isn't an object
return fallback if typeof obj != 'object'
for suspect in suspects
return fallback unless obj[suspect]?
return fallback unless typeof suspect == 'string' && obj[suspect]?
obj = obj[suspect]
return obj

Expand Down Expand Up @@ -42,5 +42,8 @@ check =
defaultFallback: false

#export as CJS module
module.exports = check if module?.exports?;
if module?.exports?
module.exports = check
else
return check

4 changes: 3 additions & 1 deletion check.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 120f7e1

Please sign in to comment.