Browse Source

AMBARI-12051. Yarn config tab not loading when localhost is present in hive JDBC url. (jaimin)

Jaimin Jetly 10 years ago
parent
commit
4ce1e8340c
2 changed files with 16 additions and 1 deletions
  1. 1 1
      ambari-web/app/utils/validator.js
  2. 15 0
      ambari-web/test/utils/validator_test.js

+ 1 - 1
ambari-web/app/utils/validator.js

@@ -108,7 +108,7 @@ module.exports = {
    */
    */
   isHostname: function(value) {
   isHostname: function(value) {
     var regex = /(?=^.{3,254}$)(^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*(\.[a-zA-Z]{1,62})$)/;
     var regex = /(?=^.{3,254}$)(^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*(\.[a-zA-Z]{1,62})$)/;
-    return regex.test(value);
+    return value === 'localhost' || regex.test(value);
   },
   },
 
 
   hasSpaces: function(value) {
   hasSpaces: function(value) {

+ 15 - 0
ambari-web/test/utils/validator_test.js

@@ -424,4 +424,19 @@ describe('validator', function () {
       })
       })
     });
     });
   });
   });
+
+  describe('#isHostname()', function() {
+    var tests = [
+      {m:'"localhost" - valid',i:'localhost',e:true},
+      {m:'"c6401.apache.ambari.org" - valid',i:'c6401.apache.ambari.org',e:true},
+      {m:'"c6401.org" - valid',i:'c6401.org',e:true},
+      {m:'"c6401" - invalid',i:'c6401',e:false},
+      {m:'"c6401." - invalid',i:'c6401.',e:false}
+    ];
+    tests.forEach(function(test) {
+      it(test.m + ' ', function () {
+        expect(validator.isHostname(test.i)).to.equal(test.e);
+      })
+    });
+  });
 });
 });