X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=client%2Fsrc%2Fapp%2Fshared%2Fforms%2Fform-validators%2Fhost.validator.ts;h=03e810fdb902c2e23bb7359d2741aff6a8025c10;hb=df98563e2104b82b119c00a3cd83cd0dc1242d25;hp=ec417e0795601cd1981ba21963a8ec260d7ecc3d;hpb=46757b477c1adb5f98060d15998a3852e18902a6;p=github%2FChocobozzz%2FPeerTube.git 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 ec417e079..03e810fdb 100644 --- a/client/src/app/shared/forms/form-validators/host.validator.ts +++ b/client/src/app/shared/forms/form-validators/host.validator.ts @@ -1,14 +1,14 @@ -import { FormControl } from '@angular/forms'; +import { FormControl } from '@angular/forms' -export function validateHost(c: FormControl) { +export function validateHost (c: FormControl) { // Thanks to http://stackoverflow.com/a/106223 const 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: { valid: false } - }; + } }