Skip to content

Commit

Permalink
feat: handling invalid custom emoji
Browse files Browse the repository at this point in the history
  • Loading branch information
wonderlandpark committed Feb 23, 2021
1 parent 97ef0d1 commit fe7af34
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions utils/ShowdownExtensions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Emoji, EmojiSyntax, Heading, ImageTag } from './Regex'
import Twemoji from 'twemoji'
import { KoreanbotsEmoji } from './Constants'
import { emoji } from 'node-emoji'

export const anchorHeader = {
type: 'output',
Expand Down Expand Up @@ -34,7 +35,7 @@ export const customEmoji = {
type: 'output',
regex: EmojiSyntax,
replace: function(__match: string, name: string) {
if(!name) return `:${name}:`
return `<img class="emoji" draggable="false" alt="${name}" src="${KoreanbotsEmoji[name]}"/>`
if(!name || !KoreanbotsEmoji[name]) return `:${name}:`
return `<img class="emoji special" draggable="false" alt="${name}" src="${KoreanbotsEmoji[name]}"/>`
}
}

0 comments on commit fe7af34

Please sign in to comment.