Update scripts

This commit is contained in:
freearhey 2023-10-08 02:13:58 +03:00
parent 0feb6b1e89
commit f0cbc45e14
4 changed files with 29 additions and 34 deletions

17
scripts/core/idCreator.ts Normal file
View file

@ -0,0 +1,17 @@
export class IDCreator {
create(name: string, country: string): string {
const slug = normalize(name)
const code = country.toLowerCase()
return `${slug}.${code}`
}
}
function normalize(name: string) {
return name
.replace(/^@/gi, 'At')
.replace(/^&/i, 'And')
.replace(/\+/gi, 'Plus')
.replace(/\s-(\d)/gi, ' Minus$1')
.replace(/[^a-z\d]+/gi, '')
}