Commit fba2c4a1 authored by ZTGAME\jiangpengqing's avatar ZTGAME\jiangpengqing

gitlab custom prot support

parent 0d91ae6e
...@@ -94,7 +94,7 @@ var gitUrlPatternItems = { ...@@ -94,7 +94,7 @@ var gitUrlPatternItems = {
// generate URL: https://gitlab.com/{org}/{repo}/blob/{branch}/{path} // generate URL: https://gitlab.com/{org}/{repo}/blob/{branch}/{path}
'testRegex': /^(https?:\/\/)?(\S+\@)?(\S+\.)?gitlab\.com(\/|:).*/i, 'testRegex': /^(https?:\/\/)?(\S+\@)?(\S+\.)?gitlab\.com(\/|:).*/i,
'generateUrl': function (gitInfo) { 'generateUrl': function (gitInfo) {
var url = normalizeGitUrlToHttps(gitInfo.repo); var url = normalizeGitUrlToHttpsForCustomPort(gitInfo.repo,6);
url = getRepoWithoutGitExtension(url); url = getRepoWithoutGitExtension(url);
url += '/blob' + '/' + gitInfo.branch + '/' + gitInfo.path; url += '/blob' + '/' + gitInfo.branch + '/' + gitInfo.path;
if (gitInfo.startLine && gitInfo.startLine > 0) { if (gitInfo.startLine && gitInfo.startLine > 0) {
...@@ -103,7 +103,7 @@ var gitUrlPatternItems = { ...@@ -103,7 +103,7 @@ var gitUrlPatternItems = {
return url; return url;
}, },
'generateNewFileUrl': function (gitInfo, uid) { 'generateNewFileUrl': function (gitInfo, uid) {
var url = normalizeGitUrlToHttps(gitInfo.repo); var url = normalizeGitUrlToHttpsForCustomPort(gitInfo.repo,6);
url = getRepoWithoutGitExtension(url); url = getRepoWithoutGitExtension(url);
url += '/new'; url += '/new';
url += '/' + gitInfo.branch; url += '/' + gitInfo.branch;
...@@ -141,6 +141,13 @@ function getRepoWithoutGitExtension(repo) { ...@@ -141,6 +141,13 @@ function getRepoWithoutGitExtension(repo) {
return repo; return repo;
} }
function normalizeGitUrlToHttpsForCustomPort(repo,port) {
var pos = repo.indexOf('@');
if (pos == -1) return repo;
//return 'https://' + repo.substr(pos + 1).replace(/:[0-9]+/g, '').replace(/:/g, '/');
return 'https://' + repo.substr(pos + 1).replace(/:[0-9]+/g, ':'+port);
}
function normalizeGitUrlToHttps(repo) { function normalizeGitUrlToHttps(repo) {
var pos = repo.indexOf('@'); var pos = repo.indexOf('@');
if (pos == -1) return repo; if (pos == -1) return repo;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment