fix(emoji): asterisk should not be treated as emoji (#668)
This commit is contained in:
parent
35a42c9fd3
commit
3dae883761
2
package-lock.json
generated
2
package-lock.json
generated
|
@ -508,7 +508,7 @@
|
|||
},
|
||||
"util": {
|
||||
"version": "0.10.3",
|
||||
"resolved": "http://registry.npmjs.org/util/-/util-0.10.3.tgz",
|
||||
"resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz",
|
||||
"integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=",
|
||||
"requires": {
|
||||
"inherits": "2.0.1"
|
||||
|
|
|
@ -9,7 +9,7 @@ export function replaceEmoji (string, replacer) {
|
|||
|
||||
function safeReplacer (substring) {
|
||||
// emoji regex matches digits and pound sign https://git.io/fpl6J
|
||||
if (substring.match(/^[0-9#]+$/)) {
|
||||
if (substring.match(/^[0-9#*]+$/)) {
|
||||
return substring
|
||||
}
|
||||
return replacer(substring)
|
||||
|
|
|
@ -60,12 +60,16 @@ describe('test-emoji.js', function () {
|
|||
)
|
||||
})
|
||||
|
||||
it('does not replace digits or pound', function () {
|
||||
it('does not replace non-emoji characters', function () {
|
||||
let replacer = _ => `<div>${_}</div>`
|
||||
assert.strictEqual(
|
||||
replaceEmoji(`it's over #9000`, replacer),
|
||||
`it's over #9000`
|
||||
)
|
||||
assert.strictEqual(
|
||||
replaceEmoji(`woot !@#$%^&*()~` + '`' + `{[}]:;"'<,>.?/£`, replacer),
|
||||
`woot !@#$%^&*()~` + '`' + `{[}]:;"'<,>.?/£`
|
||||
)
|
||||
})
|
||||
|
||||
it('does not replace emoji inside HTML tags', function () {
|
||||
|
|
Loading…
Reference in a new issue