diff --git a/lib/routes/firefox/release.js b/lib/routes/firefox/release.js index 5da5971ef7..77e7fb311c 100644 --- a/lib/routes/firefox/release.js +++ b/lib/routes/firefox/release.js @@ -2,36 +2,29 @@ const axios = require('../../utils/axios'); const cheerio = require('cheerio'); module.exports = async (ctx) => { - if (ctx.params.platform === 'desktop') { - ctx.params.platform = ''; + const { platform } = ctx.params; + let devicePlatform = platform.replace('-', '/'); + if (devicePlatform === 'desktop') { + devicePlatform = ''; } - if (ctx.params.platform === 'android-beta') { - ctx.params.platform = 'android/beta'; - } - const response = await axios.get(`https://www.mozilla.org/en-US/firefox/${ctx.params.platform}/notes/`); - const data = response.data; - const $ = cheerio.load(data); + + const link = `https://www.mozilla.org/en-US/firefox/${devicePlatform}/notes/`; + const response = await axios.get(link); + const $ = cheerio.load(response.data); + const version = $('.c-release-version').text(); + const pubDate = new Date($('.c-release-date').text()).toUTCString(); ctx.state.data = { - title: `Firefox ${ctx.params.platform} release note`, - link: `https://www.mozilla.org/en-US/firefox/${ctx.params.platform}/notes/`, + title: `Firefox ${platform} release note`, + link, item: [ { - title: `Firefox ${ctx.params.platform} ${$('.version') - .find('h2') - .text()} release note`, - link: `https://www.mozilla.org/en-US/firefox/${ctx.params.platform}/notes/`, - description: $('.notes-section').html(), - guid: $('.version') - .find('h2') - .text(), - pubDate: new Date( - $('.version') - .find('p') - .text() - ).toUTCString(), + title: `Firefox ${platform} ${version} release note`, + link, + description: $('.c-release-notes').html(), + guid: `${platform} ${version}`, + pubDate, }, ], - description: $('.description').text(), }; };