From 2b53c69fa7738de3f5f1caa1662b3172df5514b4 Mon Sep 17 00:00:00 2001 From: Kate Hudson Date: Thu, 22 May 2014 13:06:47 -0400 Subject: [PATCH] Check if worksheet_id is a number and greater than 0, since 0 is a valid worksheet id --- index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 183e5b5..138af8c 100644 --- a/index.js +++ b/index.js @@ -92,7 +92,10 @@ module.exports = function( ss_key, auth_id ){ }); } this.addRow = function( worksheet_id, data, cb ){ - if( !worksheet_id ) throw new Error("Worksheet not specified."); + worksheet_id = parseInt(worksheet_id); + if (typeof worksheet_id !== 'number' || worksheet_id < 0) { + throw new Error('Valid worksheet not specified.'); + } var data_xml = '' + "\n"; Object.keys(data).forEach(function(key) { @@ -317,4 +320,4 @@ var xmlSafeColumnName = function(val){ if (!val) return ''; return String(val).replace(/\s+/g, '') .toLowerCase(); -} \ No newline at end of file +}