]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/forms/form-validators/host.validator.ts
Relax on tags (accept any characters and not required anymore)
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / forms / form-validators / host.validator.ts
index 9cb46d36133fe742e975704b73585f15c1ccd314..ec417e0795601cd1981ba21963a8ec260d7ecc3d 100644 (file)
@@ -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
+  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: {