1
0
Fork 0

Allow specifying "_" as collection prefix.

This commit is contained in:
Alan Plum 2014-06-30 14:43:59 +02:00
parent 6a89d78929
commit 288c6d8d31
1 changed files with 3 additions and 4 deletions

View File

@ -192,14 +192,13 @@ function extendContext (context, app, root) {
'use strict';
var cp = context.collectionPrefix;
var cname = "";
if (cp !== "") {
cname = cp + "_";
if (cp !== "" && cp !== "_") {
cp += "_";
}
context.collectionName = function (name) {
var replaced = (cname + name).replace(/[^a-zA-Z0-9]/g, '_').replace(/(^_+|_+$)/g, '').substr(0, 64);
var replaced = (cp + name.replace(/[^a-zA-Z0-9]/g, '_').replace(/(^_+|_+$)/g, '')).substr(0, 64);
if (replaced.length === 0) {
throw new Error("Cannot derive collection name from '" + name + "'");