Skip to content

Commit

Permalink
Raji/manu: Fix the bug in validating sheet IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajeswari Krishnakumar committed Nov 4, 2016
1 parent 354b8d0 commit 44066d8
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/util/sheetValidator.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
const SheetNotFoundError = require('../../src/exceptions/sheetNotFoundError');
const ExceptionMessages = require('./exceptionMessages');

const SheetValidator = function (sheetId) {
const SheetValidator = function (sheetReference) {
var self = {};

self.verifySheet = function () {
var sheetUrl = '';
if (sheetId.trim().startsWith("http")) {
sheetUrl = sheetId;
var sheetId = '';
if (sheetReference.trim().startsWith("http")) {
var result = sheetReference.match("d\\/(.*?)\\/pubhtml");
if(result === null) {
throw new SheetNotFoundError(ExceptionMessages.SHEET_NOT_FOUND);
}
sheetId = result[1];

} else {
sheetUrl = "https://spreadsheets.google.com/feeds/worksheets/" + sheetId + "/public/basic?alt=json";
sheetId = sheetReference;
}

var sheetUrl = "https://spreadsheets.google.com/feeds/worksheets/" + sheetId + "/public/basic?alt=json";

var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", sheetUrl, false);
xmlhttp.withCredentials = false;
Expand Down

0 comments on commit 44066d8

Please sign in to comment.