fix(emoji): asterisk should not be treated as emoji (#668)
This commit is contained in:
parent
35a42c9fd3
commit
3dae883761
|
@ -508,7 +508,7 @@
|
||||||
},
|
},
|
||||||
"util": {
|
"util": {
|
||||||
"version": "0.10.3",
|
"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=",
|
"integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=",
|
||||||
"requires": {
|
"requires": {
|
||||||
"inherits": "2.0.1"
|
"inherits": "2.0.1"
|
||||||
|
|
|
@ -9,7 +9,7 @@ export function replaceEmoji (string, replacer) {
|
||||||
|
|
||||||
function safeReplacer (substring) {
|
function safeReplacer (substring) {
|
||||||
// emoji regex matches digits and pound sign https://git.io/fpl6J
|
// emoji regex matches digits and pound sign https://git.io/fpl6J
|
||||||
if (substring.match(/^[0-9#]+$/)) {
|
if (substring.match(/^[0-9#*]+$/)) {
|
||||||
return substring
|
return substring
|
||||||
}
|
}
|
||||||
return replacer(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>`
|
let replacer = _ => `<div>${_}</div>`
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
replaceEmoji(`it's over #9000`, replacer),
|
replaceEmoji(`it's over #9000`, replacer),
|
||||||
`it's over #9000`
|
`it's over #9000`
|
||||||
)
|
)
|
||||||
|
assert.strictEqual(
|
||||||
|
replaceEmoji(`woot !@#$%^&*()~` + '`' + `{[}]:;"'<,>.?/£`, replacer),
|
||||||
|
`woot !@#$%^&*()~` + '`' + `{[}]:;"'<,>.?/£`
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('does not replace emoji inside HTML tags', function () {
|
it('does not replace emoji inside HTML tags', function () {
|
||||||
|
|
Loading…
Reference in New Issue