From 447fde277497dfff73310dc12bf79fb576139b94 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sun, 27 Nov 2016 17:45:00 +0100 Subject: Client: improve host regex --- client/src/app/shared/forms/form-validators/host.validator.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'client/src/app/shared/forms/form-validators') diff --git a/client/src/app/shared/forms/form-validators/host.validator.ts b/client/src/app/shared/forms/form-validators/host.validator.ts index 9cb46d361..ea3e43cb1 100644 --- a/client/src/app/shared/forms/form-validators/host.validator.ts +++ b/client/src/app/shared/forms/form-validators/host.validator.ts @@ -1,7 +1,10 @@ import { FormControl } from '@angular/forms'; export function validateHost(c: FormControl) { - let HOST_REGEXP = new RegExp('^(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$'); + // Thanks to http://stackoverflow.com/a/106223 + let HOST_REGEXP = new RegExp( + '^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$' + ); return HOST_REGEXP.test(c.value) ? null : { validateHost: { -- cgit v1.2.3