1 | function 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 |
|
16 | console.log(t("a.git"));
|
17 | console.log(t("a.git#b"));
|
18 | console.log(t("a#b"));
|
19 | console.log(t("a"));
|