Browse Source

throw exception if string is not selected length

master
s2 4 months ago
parent
commit
f82de05f4b
1 changed files with 3 additions and 0 deletions
  1. +3
    -0
      lib/secure-random-string.js

+ 3
- 0
lib/secure-random-string.js View File

@@ -31,6 +31,9 @@ function srs(options, cb) {
} else {
string = string.replace(/\//g, '_').replace(/\+/g, '-');
}
if (string.length < length) {
throw new Error(`Generated string is too short. Please catch this Error and try again.`);
}
return string.substr(0, length);
}
};


Loading…
Cancel
Save