1
0
mirror of https://github.com/S2-/securerandomstring.git synced 2025-08-02 02:10:05 +02:00

throw exception if string is not selected length

This commit is contained in:
s2
2020-04-08 18:19:54 +02:00
parent 94f2eadf63
commit f82de05f4b

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);
}
};