forked from cybrespace/pinafore
fix(emoji): emoji replacer should ignore pound sign (#666)
* fix(emoji): emoji replacer should ignore pound sign * add test * fix regex
This commit is contained in:
parent
5f5cb0d36d
commit
d9e79daa6a
|
@ -8,7 +8,8 @@ export function replaceEmoji (string, replacer) {
|
|||
let emojiRegex = getEmojiRegex()
|
||||
|
||||
function safeReplacer (substring) {
|
||||
if (substring.match(/^[0-9]+$/)) { // for some reason, emoji-regex matches digits
|
||||
// emoji regex matches digits and pound sign https://git.io/fpl6J
|
||||
if (substring.match(/^[0-9#]+$/)) {
|
||||
return substring
|
||||
}
|
||||
return replacer(substring)
|
||||
|
|
|
@ -60,11 +60,11 @@ describe('test-emoji.js', function () {
|
|||
)
|
||||
})
|
||||
|
||||
it('does not replace digits', function () {
|
||||
it('does not replace digits or pound', function () {
|
||||
let replacer = _ => `<div>${_}</div>`
|
||||
assert.strictEqual(
|
||||
replaceEmoji(`it's over 9000`, replacer),
|
||||
`it's over 9000`
|
||||
replaceEmoji(`it's over #9000`, replacer),
|
||||
`it's over #9000`
|
||||
)
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue