mirror of
https://github.com/iptv-org/database.git
synced 2024-11-26 20:41:27 -05:00
17 lines
388 B
TypeScript
17 lines
388 B
TypeScript
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, '')
|
|
}
|