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

4 Commits

Author SHA1 Message Date
s2
f7e565bcc7 1.1.3 2020-04-08 18:20:02 +02:00
s2
f82de05f4b throw exception if string is not selected length 2020-04-08 18:19:54 +02:00
s2
94f2eadf63 1.1.2 2019-07-13 15:44:08 +02:00
s2
394d13d5a7 1.1.1 2019-07-13 15:43:41 +02:00
2 changed files with 7 additions and 2 deletions

View File

@@ -31,6 +31,9 @@ function srs(options, cb) {
} else { } else {
string = string.replace(/\//g, '_').replace(/\+/g, '-'); 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); return string.substr(0, length);
} }
}; };

View File

@@ -1,6 +1,6 @@
{ {
"name": "secure-random-string", "name": "secure-random-string",
"version": "1.1.0", "version": "1.1.3",
"description": "Generates a secure random string with a given length", "description": "Generates a secure random string with a given length",
"main": "lib/secure-random-string.js", "main": "lib/secure-random-string.js",
"scripts": { "scripts": {
@@ -19,7 +19,9 @@
"token" "token"
], ],
"author": "Simon Santoro", "author": "Simon Santoro",
"contributors": ["Mark Stosberg <mark@rideamigos.com>"], "contributors": [
"Mark Stosberg <mark@rideamigos.com>"
],
"license": "MIT", "license": "MIT",
"bugs": { "bugs": {
"url": "https://github.com/S2-/securerandomstring/issues" "url": "https://github.com/S2-/securerandomstring/issues"