24 lines
505 B
JavaScript
24 lines
505 B
JavaScript
const file = require('./file')
|
|
const parser = require('./parser')
|
|
const transliteration = require('transliteration')
|
|
|
|
const id = {}
|
|
|
|
id.generate = function (title, filepath) {
|
|
const name = parser.parseChannelName(title)
|
|
const code = parser.parseCountryCode(filepath)
|
|
|
|
if (name && code) {
|
|
const slug = transliteration
|
|
.transliterate(name)
|
|
.replace(/\+/gi, 'Plus')
|
|
.replace(/[^a-z\d]+/gi, '')
|
|
|
|
return `${slug}.${code.toLowerCase()}`
|
|
}
|
|
|
|
return null
|
|
}
|
|
|
|
module.exports = id
|