dragonroll/backend/node_modules/shortid/lib/is-valid.js

16 lines
348 B
JavaScript

'use strict';
var alphabet = require('./alphabet');
function isShortId(id) {
if (!id || typeof id !== 'string' || id.length < 6 ) {
return false;
}
var nonAlphabetic = new RegExp('[^' +
alphabet.get().replace(/[|\\{}()[\]^$+*?.-]/g, '\\$&') +
']');
return !nonAlphabetic.test(id);
}
module.exports = isShortId;