From 723f05bfca2219813dba3b1f59d403b7cec20311 Mon Sep 17 00:00:00 2001 From: Julian Krauser Date: Sun, 15 Sep 2024 10:48:01 +0200 Subject: [PATCH] url friendly random strings --- src/helpers/stringHelper.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/helpers/stringHelper.ts b/src/helpers/stringHelper.ts index b76a6aa..f41c660 100644 --- a/src/helpers/stringHelper.ts +++ b/src/helpers/stringHelper.ts @@ -9,6 +9,9 @@ export abstract class StringHelper { // randomString += charSet.substring(randomPoz, randomPoz + 1); // } // return randomString; - return crypto.randomBytes(len).toString("base64"); + return crypto + .randomBytes(len) + .toString("base64") + .replace(/[^a-zA-Z0-9]/g, ""); } }