diff --git a/src/utils.js b/src/utils.js index ca1502b..a2c6931 100644 --- a/src/utils.js +++ b/src/utils.js @@ -110,8 +110,8 @@ utils.escapeString = function (string, defaultValue = '') { } utils.convertToXMLTV = function ({ config, channels, programs }) { + const url = config.site ? 'https://' + config.site : null let output = `\r\n` - for (let channel of channels) { const id = this.escapeString(channel['xmltv_id']) const displayName = this.escapeString(channel.name) @@ -120,6 +120,9 @@ utils.convertToXMLTV = function ({ config, channels, programs }) { const logo = this.escapeString(channel.logo) output += `` } + if (url) { + output += `${url}` + } output += `\r\n` } diff --git a/tests/utils.test.js b/tests/utils.test.js index f8d57aa..0047f99 100644 --- a/tests/utils.test.js +++ b/tests/utils.test.js @@ -61,9 +61,10 @@ it('can convert object to xmltv string', () => { lang: 'it' } ] - const output = utils.convertToXMLTV({ channels, programs }) + const config = { site: 'example.com' } + const output = utils.convertToXMLTV({ config, channels, programs }) expect(output).toBe( - '\r\n1 TV\r\n2 TV\r\nProgram 1Description for Program 1Test\r\n' + '\r\n1 TVhttps://example.com\r\n2 TVhttps://example.com\r\nProgram 1Description for Program 1Test\r\n' ) })