fixed stop yelling error for unset local emojis

This commit is contained in:
CRIMX 2016-12-25 18:18:12 +08:00
parent d7e1ca5e29
commit 99eadc8f58

View file

@ -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)) {