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