UNPKG

381 BJavaScriptView Raw
1function t(name) {
2 const object = { };
3 let right = false;
4 const res = name.replace(/((\.git)?(#(.*))?)$/, (match, a, b, c, branch) => {
5 if (branch) {
6 object.branch = branch;
7 }
8 right = a.length > 0;
9
10 return "";
11 });
12
13 return [name, res, right, object];
14}
15
16console.log(t("a.git"));
17console.log(t("a.git#b"));
18console.log(t("a#b"));
19console.log(t("a"));