fix(theme-common): fix extractLeadingEmoji() edge case with digits#12072
fix(theme-common): fix extractLeadingEmoji() edge case with digits#12072ian-rehwinkel-lablions wants to merge 2 commits into
extractLeadingEmoji() edge case with digits#12072Conversation
|
Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
✅ [V2]
To edit notification comments on pull requests, go to your Netlify project configuration. |
extractLeadingEmoji()edge case with digits
extractLeadingEmoji()edge case with digitsextractLeadingEmoji() edge case with digits
slorber
left a comment
There was a problem hiding this comment.
Thanks, LGTM 👍
FYI I replaced your impl with {RGI_Emoji} unicode set, which apparently conveys the intent better, and now has enough browser/server runtime support to be used.
Please sign the CLA: I can't merge PRs without that, and would need to re-recreate one to merge it
| }); | ||
|
|
||
| it('extract emoji digits', () => { | ||
| expect(extractLeadingEmoji('1️⃣ Hello World')).toEqual({ |
There was a problem hiding this comment.
I added this extra test case, that was failing with your impl
| // Leading grapheme contains an emoji | ||
| // Covers flags/ZWJ/skin tones, excludes digits | ||
| // See https://github.com/facebook/docusaurus/pull/12072 | ||
| if (!/^\p{RGI_Emoji}$/v.test(grapheme)) { |
There was a problem hiding this comment.
Here's a better option, apparently, both our test cases now pass successfully
Pre-flight checklist
Motivation
This fixes this issue.
Test Plan
A simple Unit-Test checks that numbers are no longer recognized as emoji.