t-comm
Version:
专业、稳定、纯粹的工具库
25 lines (21 loc) • 523 B
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
function transformGitToSSH(link) {
if (link === void 0) {
link = '';
}
if (!link.startsWith('http')) {
return link;
}
var reg = /https:\/\/([^/]+)\/(.*)$/;
var match = link.match(reg);
if (!match) {
return '';
}
var result = "git@".concat(match[1], ":").concat(match[2]);
if (result.endsWith('.git')) {
return result;
}
return "".concat(result, ".git");
}
exports.transformGitToSSH = transformGitToSSH;