You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
464 B

  1. 'use strict';
  2. var alphabet = require('./alphabet');
  3. function isShortId(id) {
  4. if (!id || typeof id !== 'string' || id.length < 6 ) {
  5. return false;
  6. }
  7. var characters = alphabet.characters();
  8. var invalidCharacters = id.split('').map(function(char){
  9. if (characters.indexOf(char) === -1) {
  10. return char;
  11. }
  12. }).join('').split('').join('');
  13. return invalidCharacters.length === 0;
  14. }
  15. module.exports = isShortId;