github
3289 of 3896 branches covered (84.42%)
66 of 70 new or added lines in 3 files covered. (94.29%)
762 existing lines in 27 files now uncovered.25213 of 31528 relevant lines covered (79.97%)
2375.78 hits per line
1 |
import { slugify } from 'transliteration'; |
4✔ |
2 |
|
4✔ |
3 |
export function convertNameToValidCharacter(name: string, maxLength = 10): string { |
|
4 |
let cleanedName = slugify(name, { allowedChars: 'a-zA-Z0-9_', separator: '_', lowercase: false }); |
9,526✔ |
5 |
|
9,526✔ |
6 |
if (cleanedName === '' || /^_+$/.test(cleanedName)) { |
|
UNCOV
7
|
return 'unnamed'; |
× |
UNCOV
8
|
} |
× |
9 |
|
9,526✔ |
10 |
if (!/^[a-z]/i.test(cleanedName)) {
|
|
UNCOV
11
|
cleanedName = 't' + cleanedName;
|
× |
UNCOV
12
|
} |
× |
13 |
|
9,526✔ |
14 |
cleanedName = cleanedName.substring(0, maxLength);
|
9,526✔ |
15 |
|
9,526✔ |
16 |
return cleanedName;
|
9,526✔ |
17 |
} |
9,526✔ |