"use strict"; /// var plugins = require("./smartstring.plugins"); /* ---------------------------------------------- * * ------------------ classes ------------------- * * ---------------------------------------------- */ var gitRepo = (function () { function gitRepo(stringArg, tokenArg) { var regexMatches = gitRegex(stringArg); this.host = regexMatches[1]; this.user = regexMatches[2]; this.repo = regexMatches[3]; this.accessToken = tokenArg; this.sshUrl = gitLink(this.host, this.user, this.repo, this.accessToken, "ssh"); this.httpsUrl = gitLink(this.host, this.user, this.repo, this.accessToken, "https"); } ; return gitRepo; }()); /* ---------------------------------------------- * * ------------------ helpers ------------------- * * ---------------------------------------------- */ var gitRegex = function (stringArg) { var regexString = /(?:git\+|git\@|https\:\/\/|)(?:https\:\/\/|)([^\/|\:]*)(?:\/|:)([^\/]+)*(?:\/|:)([^\.]+)/; var regexMatches = regexString.exec(stringArg); return regexMatches; }; var gitLink = function (hostArg, userArg, repoArg, tokenArg, linkTypeArg) { if (tokenArg === void 0) { tokenArg = ""; } var returnString; if (tokenArg !== "") { tokenArg = tokenArg + "@"; } switch (linkTypeArg) { case "https": returnString = "https://" + tokenArg + hostArg + "/" + userArg + "/" + repoArg + ".git"; break; case "ssh": returnString = "git@" + hostArg + ":" + userArg + "/" + repoArg + ".git"; break; default: plugins.beautylog.error("Link Type " + linkTypeArg + " not known"); break; } return returnString; }; /* ---------------------------------------------- * * ------------------ exports ------------------- * * ---------------------------------------------- */ var git = function (stringArg, tokenArg) { var localGitRepo = new gitRepo(stringArg, tokenArg); return localGitRepo; }; module.exports = git; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3RyaW5nLmdpdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsNENBQTRDO0FBQzVDLElBQU8sT0FBTyxXQUFXLHVCQUF1QixDQUFDLENBQUM7QUFFbEQ7O29EQUVvRDtBQUNwRDtJQU9JLGlCQUFZLFNBQWdCLEVBQUMsUUFBZ0I7UUFDekMsSUFBSSxZQUFZLEd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