diff --git a/lib/secure-random-string.js b/lib/secure-random-string.js index cc67b9c..398087b 100644 --- a/lib/secure-random-string.js +++ b/lib/secure-random-string.js @@ -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); } };