-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
Copy pathutils.ts
45 lines (40 loc) · 1.41 KB
/
utils.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
export function removeParenthesesFromEnd(inputString) {
// Check if the string ends with parentheses
if (inputString.endsWith("()")) {
// Remove the parentheses from the end
return inputString.slice(0, -2);
} else {
// If no parentheses at the end, return the original string
return inputString;
}
}
export function replaceLastDotWithHash(inputString) {
const lastDotIndex = inputString.lastIndexOf('.');
if (lastDotIndex !== -1) {
const stringWithHash = inputString.slice(0, lastDotIndex) + '#' + inputString.slice(lastDotIndex + 1);
return stringWithHash;
} else {
// If there is no dot in the string, return the original string
return inputString;
}
}
export function separateGoPath(inputString) {
const lastDotIndex = inputString.lastIndexOf('.');
if (lastDotIndex !== -1) {
const stringWith = inputString.slice(0, lastDotIndex);
return stringWith;
} else {
// If there is no dot in the string, return the original string
return inputString;
}
}
export function separateGoTestName(inputString) {
const lastDotIndex = inputString.lastIndexOf('.');
if (lastDotIndex !== -1) {
const stringWith = inputString.slice(lastDotIndex + 1);
return stringWith;
} else {
// If there is no dot in the string, return the original string
return inputString;
}
}