From 99eadc8f58552fca1cf5ac1f7c148a813371f82e Mon Sep 17 00:00:00 2001 From: CRIMX Date: Sun, 25 Dec 2016 18:18:12 +0800 Subject: [PATCH] fixed stop yelling error for unset local emojis --- index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 6cf0180..fbb9813 100644 --- a/index.js +++ b/index.js @@ -23,9 +23,9 @@ if (options.enable !== false) { // load custom emojis var localEmojis = options.localEmojis // JSON string - if (!_.isObject(localEmojis)) { + if (_.isString(localEmojis)) { try { - localEmojis = JSON.parse(localEmojis.toString()) + localEmojis = JSON.parse(localEmojis) Object.keys(localEmojis).forEach(function (name) { if (_.isString(localEmojis[name])) { localEmojis[name] = { @@ -38,6 +38,9 @@ if (options.enable !== false) { console.warn('filter-github-emojis: local emojis error') } } + if (!_.isObject(localEmojis)) { + localEmojis = {} + } Object.keys(localEmojis).forEach(function (name) { var codepoints = localEmojis[name].codepoints if (codepoints && !_.isArray(codepoints)) {