From 18f95b7e13d1c426529d469712a800e8249c4a6f Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Mon, 27 Mar 2023 15:56:42 +0300 Subject: [PATCH] Update URL validator regex in order to allow www2. --- utils/string-utils.class.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/string-utils.class.ts b/utils/string-utils.class.ts index ced29bc7..61d45b48 100644 --- a/utils/string-utils.class.ts +++ b/utils/string-utils.class.ts @@ -261,9 +261,9 @@ export class Identifier { export class StringUtils { - public static urlRegex = 'https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.' + - '[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.' + - '[a-zA-Z0-9]+\.[^\s]{2,}'; + public static urlRegex = 'https?:\\/\\/(?:www(2?)\\.|(?!www(2?)))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\\.[^\\s]{2,}|www(2?)\\.' + + '[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\\.[^\\s]{2,}|https?:\\/\\/(?:www(2?)\\.|(?!www(2?)))[a-zA-Z0-9]+\\.[^\\s]{2,}|www(2?)\\.' + + '[a-zA-Z0-9]+\\.[^\\s]{2,}'; public static routeRegex = '^[a-zA-Z0-9\/][a-zA-Z0-9\/-]*$';