Skip to content

Commit

Permalink
Check if worksheet_id is a number and greater than 0, since 0 is a va…
Browse files Browse the repository at this point in the history
…lid worksheet id
  • Loading branch information
k88hudson committed May 23, 2014
1 parent b0946ee commit 2b53c69
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gsx="http://schemas.google.com/spreadsheets/2006/extended">' + "\n";
Object.keys(data).forEach(function(key) {
Expand Down Expand Up @@ -317,4 +320,4 @@ var xmlSafeColumnName = function(val){
if (!val) return '';
return String(val).replace(/\s+/g, '')
.toLowerCase();
}
}

0 comments on commit 2b53c69

Please sign in to comment.