Update the create project form to only normalise project names if a format is provided for the project type.

Closes #538
This commit is contained in:
Stéphane HULARD 2014-08-01 11:09:04 +02:00 committed by Dan Cryer
parent eb508baa4f
commit 4511b71448

View file

@ -245,19 +245,26 @@ function setupProjectForm()
{ {
var el = $(this); var el = $(this);
var val = el.val(); var val = el.val();
var type = $('#element-type').val();
var acceptable = { var acceptable = {
'github_ssh': /git\@github\.com\:([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)\.git/, 'github': {
'github_git': /git\:\/\/github.com\/([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)\.git/, 'ssh': /git\@github\.com\:([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)\.git/,
'github_http': /https\:\/\/github\.com\/([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)(\.git)?/, 'git': /git\:\/\/github.com\/([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)\.git/,
'bb_ssh': /git\@bitbucket\.org\:([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)\.git/, 'http': /https\:\/\/github\.com\/([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)(\.git)?/
'bb_http': /https\:\/\/[a-zA-Z0-9_\-]+\@bitbucket.org\/([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)\.git/, },
'bb_anon': /https\:\/\/bitbucket.org\/([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)(\.git)?/ 'bitbucket': {
'ssh': /git\@bitbucket\.org\:([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)\.git/,
'http': /https\:\/\/[a-zA-Z0-9_\-]+\@bitbucket.org\/([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)\.git/,
'anon': /https\:\/\/bitbucket.org\/([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)(\.git)?/
}
}; };
for(var i in acceptable) { if( acceptable[type] !== undefined ) {
if(val.match(acceptable[i])) { for(var i in acceptable[type]) {
el.val(val.replace(acceptable[i], '$1')); if(val.match(acceptable[type][i])) {
el.val(val.replace(acceptable[type][i], '$1'));
}
} }
} }
}); });
@ -272,7 +279,7 @@ function setupProjectForm()
success: function (data) { success: function (data) {
$('#loading').hide(); $('#loading').hide();
if (data.repos) { if (data && data.repos) {
$('#element-github').empty(); $('#element-github').empty();
for (var i in data.repos) { for (var i in data.repos) {
@ -288,6 +295,7 @@ function setupProjectForm()
} else { } else {
$('.github-container').slideUp(); $('.github-container').slideUp();
} }
$('#element-reference').trigger('change');
}); });
$('#element-github').change(function() $('#element-github').change(function()