Skip to content

Commit

Permalink
Merge pull request #3694 from ZitaNemeckova/allow_ssh
Browse files Browse the repository at this point in the history
Allow scm_url to take ssh with ssh protocol
(cherry picked from commit 755efe4)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1562803
  • Loading branch information
mzazrivec authored and simaishi committed Apr 2, 2018
1 parent e8c3512 commit 21492a4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 13 additions & 5 deletions app/assets/javascripts/directives/url_validation.js
@@ -1,4 +1,4 @@
ManageIQ.angular.app.directive('urlValidation', function() {
ManageIQ.angular.app.directive('urlValidation', ['nodeValidator', function(nodeValidator) {
return {
require: 'ngModel',
link: function (_scope, _elem, _attrs, ctrl) {
Expand All @@ -8,10 +8,18 @@ ManageIQ.angular.app.directive('urlValidation', function() {
}
return !!validUrl(viewValue);
};

var validUrl = function(s) {
return s.substring(0, 8) === 'https://' || s.substring(0, 7) === 'http://' || s.match(/^[-\w:.]+@.*:/);
var options = {
protocols: ['http', 'https', 'ssh'],
require_tld: true,
require_protocol: true,
require_valid_protocol: true,
allow_underscores: true,
allow_trailing_dot: false,
allow_protocol_relative_urls: true
};
var validUrl = function(url) {
return nodeValidator.isURL(url, options) || url.match(/^[-\w:.]+@.*:/);
};
}
}
});
}]);
2 changes: 1 addition & 1 deletion app/views/ansible_repository/_repository_form.html.haml
Expand Up @@ -53,7 +53,7 @@
%span.help-block{"ng-show" => "angularForm.scm_url.$error.required"}
= _("Required")
%span.help-block{"ng-show" => "angularForm.scm_url.$error.urlValidation"}
= _("URL must include a protocol (http:// or https://) or be a valid SSH path (user@server:path)")
= _("URL must include a protocol (http:// or https://) or be a valid SSH path (user@server:path or ssh://user@address:port/path)")
.form-group
%label.col-md-2.control-label
= _('SCM credentials')
Expand Down

0 comments on commit 21492a4

Please sign in to comment.