mirror of
https://github.com/iptv-org/database.git
synced 2024-11-23 11:24:10 -05:00
18 lines
388 B
TypeScript
18 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, '')
|
||
|
}
|