Use test instead of match

For spead reason
This commit is contained in:
Tommaso Allevi
2016-01-29 10:46:29 +01:00
parent a9aed0cacd
commit 49acd65520

View File

@@ -44,14 +44,16 @@ ExportAdapter.prototype.connect = function() {
// Returns a promise for a Mongo collection.
// Generally just for internal use.
var joinRegex = /^_Join:[A-Za-z0-9_]+:[A-Za-z0-9_]+/;
var otherRegex = /^[A-Za-z][A-Za-z0-9_]*$/;
ExportAdapter.prototype.collection = function(className) {
if (className !== '_User' &&
className !== '_Installation' &&
className !== '_Session' &&
className !== '_SCHEMA' &&
className !== '_Role' &&
!className.match(/^_Join:[A-Za-z0-9_]+:[A-Za-z0-9_]+/) &&
!className.match(/^[A-Za-z][A-Za-z0-9_]*$/)) {
!joinRegex.test(className) &&
!otherRegex.test(className)) {
throw new Parse.Error(Parse.Error.INVALID_CLASS_NAME,
'invalid className: ' + className);
}