diff --git a/plugins/mezuro/public/javascripts/validations.js b/plugins/mezuro/public/javascripts/validations.js index 142f896..cada4b4 100644 --- a/plugins/mezuro/public/javascripts/validations.js +++ b/plugins/mezuro/public/javascripts/validations.js @@ -8,7 +8,6 @@ function validate_code(code){ return true; } - function validate_new_repository() { if (allRequiredFieldsAreFilled())) return addressAndTypeMatch(); @@ -31,7 +30,7 @@ function addressAndTypeMatch() { var address = jQuery('#repository_address').val(); switch (type) { - case "BAZAAR": return matchBAZAAR(address); + case "BAZAAR": return matchBazaar(address); case "CVS": return matchCVS(address); case "GIT": return matchGIT(address); case "MERCURIAL": return matchMercurial(address); @@ -41,17 +40,52 @@ function addressAndTypeMatch() { } } +function matchBazaar(address) { + if (address.match(/bzr/)) + return true; + alert("Address does not match type BAZAAR chosen."); + return false; +} + +function matchCVS(address) { + if (address.match(/cvs/)) + return true; + alert("Address does not match type CVS chosen."); + return false; +} + function matchGIT(address) { - if (address.match(/^[ http(s)?:\/\/git(hub)?\. | git:\/\/git(hub.com | orious.org)\/ | git@git(hub.com | orious.org):].+.git$/)) + if (address.match(/^(http(s)?:\/\/git(hub)?\.|git:\/\/git(hub\.com|orious\.org)\/|git@git(hub\.com|orious\.org):).+.git$/)) + return true; + alert("Address does not match type GIT chosen."); + return false; +} + +function matchMercurial(address) { + if (address.match(/^(http(s)?|ssh):\/\/.*hg/)) + return true; + alert("Address does not match type MERCURIAL chosen."); + return false; +} + +function matchRemoteTarball(address) { + if (address.match(/\.tar(\..+)*$/)) + return true; + alert("Address does not match type REMOTE_TARBALL chosen."); + return false; +} + +function matchRemoteZIP(address) { + if (address.match(/\.zip$/)) return true; - alert("Adress does not match type GIT chosen."); + alert("Address does not match type REMOTE_ZIP chosen."); return false; } function matchSubversion(address) { if (address.match(/^http(s)?:\/\/.+\/svn.+$/)) return true; - alert("Adress does not match type Subversion chosen."); + alert("Address does not match type SUBVERSION chosen."); return false; } -- libgit2 0.21.2