From 06fe2ccf1684ab10088245b4da5c977812168226 Mon Sep 17 00:00:00 2001 From: Alex Ling Date: Tue, 2 Jun 2020 15:07:17 +0000 Subject: [PATCH] Handle escaped characters when filtering (#51) [skip ci] --- public/js/download.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/public/js/download.js b/public/js/download.js index ab28fa99..5c848d7b 100644 --- a/public/js/download.js +++ b/public/js/download.js @@ -242,7 +242,10 @@ const buildTable = () => { Object.entries(filters).forEach(([k, v]) => { if (v === 'All') return; if (k === 'group') { - chapters = chapters.filter(c => v in c.groups); + chapters = chapters.filter(c => { + unescaped_groups = Object.entries(c.groups).map(([g, id]) => unescapeHTML(g)); + return unescaped_groups.indexOf(v) >= 0; + }); return; } if (k === 'lang') { @@ -297,3 +300,9 @@ const buildTable = () => { }); $('#selection-controls').removeAttr('hidden'); }; + +const unescapeHTML = (str) => { + var elt = document.createElement("span"); + elt.innerHTML = str; + return elt.innerText; +};