1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-11-18 17:00:58 -05:00
Daggerbot-TS/src/helpers/UsernameHelper.ts

19 lines
709 B
TypeScript
Raw Normal View History

2023-08-30 04:34:59 -04:00
export default class UsernameHelper {
static stripName(text: string){
let matchesLeft = true;
const dirSlash = process.platform === 'linux' ? '\/' : '\\';
const array = text.split(dirSlash);
while (matchesLeft) {
let usersIndex = array.indexOf(process.platform === 'linux' ? 'media' : 'Users');
if (usersIndex < 1) matchesLeft = false;
else {
let usernameIndex = usersIndex + 1;
if (array[usernameIndex].length === 0) usernameIndex += 1;
array[usernameIndex] = '・'.repeat(array[usernameIndex].length);
array[usersIndex] = process.platform === 'linux' ? 'med\u200bia' : 'Us\u200bers';
}
return array.join(dirSlash);
}
}
}