diff --git a/lib/pre2017.js b/lib/pre2017.js index d5cbd03..a3878ec 100644 --- a/lib/pre2017.js +++ b/lib/pre2017.js @@ -86,10 +86,12 @@ async function fetchStatistics(year, html) { const statTable = $('table.wikitable.sortable > tbody > tr').slice(1) const tableByYear = statTable - .filter( - (index, element) => - removeInsideBrackets(getListText($, element, 'td')[0]) === String(year) - ) + .filter((index, element) => { + const yearStr = removeNewLine( + removeInsideBrackets(getListText($, element, 'td')[0]) + ) + return yearStr === String(year) + }) .first() const tableData = getListText($, tableByYear, 'td') @@ -114,6 +116,10 @@ function removeInsideBrackets(str) { return str.replace(/(\[.*?\]|\(.*?\)) */g, '') } +function removeNewLine(str) { + return str.replace(/\n/g, '') +} + module.exports = async () => { const wikiResponse = await fetchText(CODEIN_WIKI_URL)