* Extracts the login name and name from a given pipe-separated string. * * @param loginAndPipe - login/pipe string to extract from. * @returns An object containing the extracted `login` and `name`.
(loginAndPipe: string)
| 30 | * @returns An object containing the extracted `login` and `name`. |
| 31 | */ |
| 32 | function extractLoginName(loginAndPipe: string) { |
| 33 | if (!loginAndPipe) return { login: '', name: '' }; |
| 34 | |
| 35 | const split = loginAndPipe.split('/'); |
| 36 | const length = split.length; |
| 37 | |
| 38 | if (length < 2) return { login: '', name: '' }; |
| 39 | |
| 40 | return { |
| 41 | login: split[length - 2], |
| 42 | name: split[length - 1] |
| 43 | }; |
| 44 | } |
| 45 | |
| 46 | |
| 47 | /** |