[pve-devel] [PATCH manager 1/2] refactor DnsName regex

Dominik Csapak d.csapak at proxmox.com
Thu Jul 7 09:04:09 CEST 2016


we will need this again

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/manager6/Toolkit.js | 4 ++--
 www/manager6/Utils.js   | 2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/www/manager6/Toolkit.js b/www/manager6/Toolkit.js
index 30d8f78..decaab6 100644
--- a/www/manager6/Toolkit.js
+++ b/www/manager6/Toolkit.js
@@ -1,4 +1,4 @@
-/*global IP4_match, IP4_cidr_match, IP6_match, IP6_cidr_match, IP64_match*/
+/*global IP4_match, IP4_cidr_match, IP6_match, IP6_cidr_match, IP64_match, DnsName_match*/
 // ExtJS related things
 
 PVE.Utils.toolkit = 'extjs';
@@ -93,7 +93,7 @@ Ext.apply(Ext.form.field.VTypes, {
     HttpProxyText: gettext('Example') + ": http://username:password@host:port/",
 
     DnsName: function(v) {
-	return (/^(([a-zA-Z0-9]([a-zA-Z0-9\-]*[a-zA-Z0-9])?)\.)*([A-Za-z0-9]([A-Za-z0-9\-]*[A-Za-z0-9])?)$/).test(v);
+	return DnsName_match.test(v);
     },
     DnsNameText: gettext('This is not a valid DNS name'),
 
diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index 36c551c..96ff593 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -56,6 +56,8 @@ var IP6_bracket_match = new RegExp("^\\[(" + IPV6_REGEXP + ")\\]");
 
 var IP64_match = new RegExp("^(?:" + IPV6_REGEXP + "|" + IPV4_REGEXP + ")$");
 
+var DnsName_match = 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])?)$/);
+
 Ext.define('PVE.Utils', { statics: {
 
     // this class only contains static functions
-- 
2.1.4





More information about the pve-devel mailing list