From e51f43886b0c1c191dd1f4b0e8fceaf83034c8ba Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Fri, 21 Oct 2016 21:33:54 -0700 Subject: Fixing blank tags --- ext/bg/js/dictionary.js | 8 ++++---- ext/bg/js/util.js | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'ext') diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js index daab5ebd..1d54190e 100644 --- a/ext/bg/js/dictionary.js +++ b/ext/bg/js/dictionary.js @@ -79,7 +79,7 @@ class Dictionary { results.push({ expression: row.expression, reading: row.reading, - tags: row.tags.split(' '), + tags: splitField(row.tags), glossary: row.glossary, id: row.id }); @@ -103,9 +103,9 @@ class Dictionary { return this.db.kanji.where('character').equals(kanji).each(row => { results.push({ character: row.character, - onyomi: row.onyomi.split(' '), - kunyomi: row.kunyomi.split(' '), - tags: row.tags.split(' '), + onyomi: splitField(row.onyomi), + kunyomi: splitField(row.kunyomi), + tags: splitField(row.tags), glossary: row.meanings }); }).then(() => results); diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js index f10e4291..4e0cc671 100644 --- a/ext/bg/js/util.js +++ b/ext/bg/js/util.js @@ -112,3 +112,7 @@ function applyTagMeta(tag, meta) { return tag; } + +function splitField(field) { + return field.length === 0 ? [] : field.split(' '); +} -- cgit v1.2.3