mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
check the padID with a regular expression
This commit is contained in:
parent
f45b7ce9ea
commit
820c18c7e9
2 changed files with 27 additions and 11 deletions
|
@ -33,6 +33,9 @@ globalPads = [];
|
|||
*/
|
||||
exports.getPad = function(id, callback)
|
||||
{
|
||||
if(!exports.isValidPadId(id))
|
||||
throw new Error(id + " is not a valid padId");
|
||||
|
||||
var pad = globalPads[id];
|
||||
|
||||
//return pad if its already loaded
|
||||
|
@ -69,3 +72,9 @@ exports.doesPadExists = function(padId, callback)
|
|||
callback(err, value != null);
|
||||
});
|
||||
}
|
||||
|
||||
exports.isValidPadId = function(padId)
|
||||
{
|
||||
return /^([0-9]+\$)?[^$]{1,50}$/.test(padId);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue