From a25393e80683dbb1d2b9e305af624aa3752050d6 Mon Sep 17 00:00:00 2001 From: Rory& Date: Fri, 3 Oct 2025 20:50:48 +0200 Subject: Clean up array extensions --- src/api/util/utility/passwordStrength.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/api/util/utility') diff --git a/src/api/util/utility/passwordStrength.ts b/src/api/util/utility/passwordStrength.ts index fcd42d8d..f48b8022 100644 --- a/src/api/util/utility/passwordStrength.ts +++ b/src/api/util/utility/passwordStrength.ts @@ -20,7 +20,7 @@ import { Config } from "@spacebar/util"; const reNUMBER = /[0-9]/g; const reUPPERCASELETTER = /[A-Z]/g; -const reSYMBOLS = /[A-Z,a-z,0-9]/g; +const reSYMBOLS = /[A-Za-z0-9]/g; // const blocklist: string[] = []; // TODO: update ones passwordblocklist is stored in db /* @@ -45,12 +45,12 @@ export function checkPassword(password: string): number { } // checks for amount of Numbers - if (password.count(reNUMBER) >= minNumbers - 1) { + if (password.match(reNUMBER)?.length ?? 0 >= minNumbers - 1) { strength += 0.05; } // checks for amount of Uppercase Letters - if (password.count(reUPPERCASELETTER) >= minUpperCase - 1) { + if (password.match(reUPPERCASELETTER)?.length ?? 0 >= minUpperCase - 1) { strength += 0.05; } @@ -61,8 +61,8 @@ export function checkPassword(password: string): number { // checks if password only consists of numbers or only consists of chars if ( - password.length == password.count(reNUMBER) || - password.length === password.count(reUPPERCASELETTER) + password.length == password.match(reNUMBER)?.length || + password.length === password.match(reUPPERCASELETTER)?.length ) { strength = 0; } -- cgit 1.5.1