The Github Enterprise endpoint. Must start with http:// or https://.
@@ -509,7 +511,7 @@
+ pattern="{{ GITHUB_REGEX }}">
The Github Enterprise endpoint. Must start with http:// or https://.
diff --git a/static/directives/config/config-string-field.html b/static/directives/config/config-string-field.html
index 5cbbe8a35..7714fd541 100644
--- a/static/directives/config/config-string-field.html
+++ b/static/directives/config/config-string-field.html
@@ -3,5 +3,8 @@
+
+ {{ errorMessage }}
+
diff --git a/static/js/core-config-setup.js b/static/js/core-config-setup.js
index e6a79d4b6..0b1f42e62 100644
--- a/static/js/core-config-setup.js
+++ b/static/js/core-config-setup.js
@@ -10,6 +10,9 @@ angular.module("core-config-setup", ['angularFileUpload'])
'isActive': '=isActive'
},
controller: function($rootScope, $scope, $element, $timeout, ApiService) {
+ $scope.HOSTNAME_REGEX = '^[a-zA-Z-0-9\.]+(:[0-9]+)?$';
+ $scope.GITHUB_REGEX = '^https?://([a-zA-Z0-9]+\.?\/?)+$';
+
$scope.SERVICES = [
{'id': 'redis', 'title': 'Redis'},
@@ -69,6 +72,14 @@ angular.module("core-config-setup", ['angularFileUpload'])
]
};
+ $scope.validateHostname = function(hostname) {
+ if (hostname.indexOf('127.0.0.1') == 0 || hostname.indexOf('localhost') == 0) {
+ return 'Please specify a non-localhost hostname. "localhost" will refer to the container, not your machine.'
+ }
+
+ return null;
+ };
+
$scope.config = null;
$scope.mapped = {
'$hasChanges': false
@@ -719,7 +730,8 @@ angular.module("core-config-setup", ['angularFileUpload'])
'binding': '=binding',
'placeholder': '@placeholder',
'pattern': '@pattern',
- 'defaultValue': '@defaultValue'
+ 'defaultValue': '@defaultValue',
+ 'validator': '&validator'
},
controller: function($scope, $element) {
$scope.getRegexp = function(pattern) {
@@ -733,6 +745,8 @@ angular.module("core-config-setup", ['angularFileUpload'])
if (!binding && $scope.defaultValue) {
$scope.binding = $scope.defaultValue;
}
+
+ $scope.errorMessage = $scope.validator({'value': binding || ''});
});
}
};