Changeset View
Changeset View
Standalone View
Standalone View
assets/src/bundles/save/index.js
Show First 20 Lines • Show All 360 Lines • ▼ Show 20 Lines | export function validateSaveOriginUrl(input) { | ||||
if (validUrl) { | if (validUrl) { | ||||
const allowedProtocols = ['http:', 'https:', 'svn:', 'git:', 'rsync:', 'pserver:', 'ssh:']; | const allowedProtocols = ['http:', 'https:', 'svn:', 'git:', 'rsync:', 'pserver:', 'ssh:']; | ||||
validUrl = ( | validUrl = ( | ||||
allowedProtocols.find(protocol => protocol === originUrl.protocol) !== undefined | allowedProtocols.find(protocol => protocol === originUrl.protocol) !== undefined | ||||
); | ); | ||||
} | } | ||||
if (validUrl && originType === 'git') { | if (validUrl && originType === 'git') { | ||||
// additional checks for well known code hosting providers | |||||
switch (originUrl.hostname) { | |||||
case 'github.com': | |||||
validUrl = isGitRepoUrl(originUrl); | validUrl = isGitRepoUrl(originUrl); | ||||
break; | |||||
case 'git.code.sf.net': | |||||
validUrl = isGitRepoUrl(originUrl); | |||||
break; | |||||
case 'bitbucket.org': | |||||
validUrl = isGitRepoUrl(originUrl); | |||||
break; | |||||
default: | |||||
if (originUrl.hostname.startsWith('gitlab.')) { | |||||
validUrl = isGitRepoUrl(originUrl); | |||||
} | |||||
break; | |||||
} | |||||
} | } | ||||
if (validUrl) { | if (validUrl) { | ||||
input.setCustomValidity(''); | input.setCustomValidity(''); | ||||
} else { | } else { | ||||
input.setCustomValidity('The origin url is not valid or does not reference a code repository'); | input.setCustomValidity('The origin url is not valid or does not reference a code repository'); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 169 Lines • Show Last 20 Lines |