Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow scm_url to take ssh with ssh protocol #3694

Merged
merged 1 commit into from Mar 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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