mirror of
https://github.com/S2-/securerandomstring.git
synced 2025-08-02 10:20:05 +02:00
throw exception if string is not selected length
This commit is contained in:
@@ -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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user