Permalink
Browse files

Handle undefined parameter object and return false

  • Loading branch information...
TauZero committed Feb 21, 2012
1 parent 026d4a0 commit 970824d623226e9a60849ef4125beda67cc5073a
Showing with 10 additions and 2 deletions.
  1. +1 −0 lib/sailthru.js
  2. +2 −0 src/sailthru.coffee
  3. +7 −2 test/test_sailthru.coffee
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -379,6 +379,8 @@ class SailthruClient
# Postback API Methods
receiveOptoutPost: (params) ->
+ if typeof params is 'undefined'
+ return false
for param in ['action','email','sig']
if typeof params[param] is 'undefined'
return false
@@ -2,7 +2,7 @@ SailthruClient = require('../lib/sailthru').createSailthruClient('abcd12345','1
{testCase} = require 'nodeunit'
exports.receiveOptoutPost = (test) ->
- test.expect 6
+ test.expect 7
# Valid params
params1 =
@@ -47,7 +47,12 @@ exports.receiveOptoutPost = (test) ->
email: 'foo@bar.com'
sig: '110993c3e8786cb4ebdd509ea6115fea'
real6 = SailthruClient.receiveOptoutPost params6
- test.ok not real5
+ test.ok not real6
+
+ # No Params
+ params7 = undefined
+ real7 = SailthruClient.receiveOptoutPost params7
+ test.ok not real7
test.done()

0 comments on commit 970824d

Please sign in to comment.