arnaucube
arnaucube/raspberryGPIOhtmlserverPublic Self-hosted repository
raspberryGPIOhtmlserver/node_modules/shortid/lib/is-valid.js
node_modules/shortid/lib/is-valid.jsRaw
 1'use strict';
 2var alphabet = require('./alphabet');
 3
 4function isShortId(id) {
 5    if (!id || typeof id !== 'string' || id.length < 6 ) {
 6        return false;
 7    }
 8
 9    var characters = alphabet.characters();
10    var invalidCharacters = id.split('').map(function(char){
11        if (characters.indexOf(char) === -1) {
12            return char;
13        }
14    }).join('').split('').join('');
15
16    return invalidCharacters.length === 0;
17}
18
19module.exports = isShortId;