db/API.js, SessionManager: lot of copied & pasted code in integer parsing
Replaced with an early return, no functional changes.pull/3478/head
parent
1d45a63864
commit
05a33f1533
|
@ -137,15 +137,13 @@ exports.getRevisionChangeset = function(padID, rev, callback)
|
||||||
if (rev !== undefined && typeof rev !== "number")
|
if (rev !== undefined && typeof rev !== "number")
|
||||||
{
|
{
|
||||||
// try to parse the number
|
// try to parse the number
|
||||||
if (!isNaN(parseInt(rev)))
|
if (isNaN(parseInt(rev)))
|
||||||
{
|
|
||||||
rev = parseInt(rev);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
callback(new customError("rev is not a number", "apierror"));
|
callback(new customError("rev is not a number", "apierror"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rev = parseInt(rev);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensure this is not a negative number
|
// ensure this is not a negative number
|
||||||
|
@ -219,15 +217,13 @@ exports.getText = function(padID, rev, callback)
|
||||||
if(rev !== undefined && typeof rev != "number")
|
if(rev !== undefined && typeof rev != "number")
|
||||||
{
|
{
|
||||||
//try to parse the number
|
//try to parse the number
|
||||||
if(!isNaN(parseInt(rev)))
|
if(isNaN(parseInt(rev)))
|
||||||
{
|
|
||||||
rev = parseInt(rev);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
callback(new customError("rev is not a number", "apierror"));
|
callback(new customError("rev is not a number", "apierror"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rev = parseInt(rev);
|
||||||
}
|
}
|
||||||
|
|
||||||
//ensure this is not a negativ number
|
//ensure this is not a negativ number
|
||||||
|
@ -359,15 +355,13 @@ exports.getHTML = function(padID, rev, callback)
|
||||||
|
|
||||||
if (rev !== undefined && typeof rev != "number")
|
if (rev !== undefined && typeof rev != "number")
|
||||||
{
|
{
|
||||||
if (!isNaN(parseInt(rev)))
|
if (isNaN(parseInt(rev)))
|
||||||
{
|
|
||||||
rev = parseInt(rev);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
callback(new customError("rev is not a number","apierror"));
|
callback(new customError("rev is not a number","apierror"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rev = parseInt(rev);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rev !== undefined && rev < 0)
|
if(rev !== undefined && rev < 0)
|
||||||
|
@ -641,15 +635,13 @@ exports.saveRevision = function(padID, rev, callback)
|
||||||
if(rev !== undefined && typeof rev != "number")
|
if(rev !== undefined && typeof rev != "number")
|
||||||
{
|
{
|
||||||
//try to parse the number
|
//try to parse the number
|
||||||
if(!isNaN(parseInt(rev)))
|
if(isNaN(parseInt(rev)))
|
||||||
{
|
|
||||||
rev = parseInt(rev);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
callback(new customError("rev is not a number", "apierror"));
|
callback(new customError("rev is not a number", "apierror"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rev = parseInt(rev);
|
||||||
}
|
}
|
||||||
|
|
||||||
//ensure this is not a negativ number
|
//ensure this is not a negativ number
|
||||||
|
@ -782,15 +774,13 @@ exports.restoreRevision = function (padID, rev, callback)
|
||||||
if (rev !== undefined && typeof rev != "number")
|
if (rev !== undefined && typeof rev != "number")
|
||||||
{
|
{
|
||||||
//try to parse the number
|
//try to parse the number
|
||||||
if (!isNaN(parseInt(rev)))
|
if (isNaN(parseInt(rev)))
|
||||||
{
|
|
||||||
rev = parseInt(rev);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
callback(new customError("rev is not a number", "apierror"));
|
callback(new customError("rev is not a number", "apierror"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rev = parseInt(rev);
|
||||||
}
|
}
|
||||||
|
|
||||||
//ensure this is not a negativ number
|
//ensure this is not a negativ number
|
||||||
|
@ -1177,30 +1167,26 @@ exports.createDiffHTML = function(padID, startRev, endRev, callback){
|
||||||
if(startRev !== undefined && typeof startRev != "number")
|
if(startRev !== undefined && typeof startRev != "number")
|
||||||
{
|
{
|
||||||
//try to parse the number
|
//try to parse the number
|
||||||
if(!isNaN(parseInt(startRev)))
|
if(isNaN(parseInt(startRev)))
|
||||||
{
|
|
||||||
startRev = parseInt(startRev, 10);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
callback({stop: "startRev is not a number"});
|
callback({stop: "startRev is not a number"});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
startRev = parseInt(startRev, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
//check if rev is a number
|
//check if rev is a number
|
||||||
if(endRev !== undefined && typeof endRev != "number")
|
if(endRev !== undefined && typeof endRev != "number")
|
||||||
{
|
{
|
||||||
//try to parse the number
|
//try to parse the number
|
||||||
if(!isNaN(parseInt(endRev)))
|
if(isNaN(parseInt(endRev)))
|
||||||
{
|
|
||||||
endRev = parseInt(endRev, 10);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
callback({stop: "endRev is not a number"});
|
callback({stop: "endRev is not a number"});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
endRev = parseInt(endRev, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
//get the pad
|
//get the pad
|
||||||
|
|
|
@ -90,15 +90,13 @@ exports.createSession = function(groupID, authorID, validUntil, callback)
|
||||||
if(typeof validUntil != "number")
|
if(typeof validUntil != "number")
|
||||||
{
|
{
|
||||||
//try to parse the number
|
//try to parse the number
|
||||||
if(!isNaN(parseInt(validUntil)))
|
if(isNaN(parseInt(validUntil)))
|
||||||
{
|
|
||||||
validUntil = parseInt(validUntil);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
callback(new customError("validUntil is not a number","apierror"));
|
callback(new customError("validUntil is not a number","apierror"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
validUntil = parseInt(validUntil);
|
||||||
}
|
}
|
||||||
|
|
||||||
//ensure this is not a negativ number
|
//ensure this is not a negativ number
|
||||||
|
|
Loading…
Reference in New Issue