UNPKG

shortid

Version:

Amazingly short non-sequential url-friendly unique id generator.

16 lines (12 loc) 348 B
'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;