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:
Nolan Lawson 2018-11-20 09:42:49 -08:00 committed by GitHub
parent 5f5cb0d36d
commit d9e79daa6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View file

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

View file

@ -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`
)
})