Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: unicode parsing #2030

Merged
merged 2 commits into from
Sep 11, 2024
Merged

Conversation

akimovnet
Copy link
Contributor

@akimovnet akimovnet commented Sep 9, 2024

Description

Injs-lingui/packages/core/src/interpolate.ts there is a regular expression to test if the string has unicode values inside, it has the g flag which makes that Regexp stateful. If you render the same string twice in a row, Lingui will not parse the string a second time, because the lastIndex for that string will be after the Unicode symbol at that point. And since there is no need to keep the lastIndex state, no need for a g flag here.

The bug is reproducible, for example, in React with the StrictMode enabled.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Examples update

Fixes #2028

Checklist

  • I have read the CONTRIBUTING and CODE_OF_CONDUCT docs
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation (if appropriate)

Copy link

vercel bot commented Sep 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
js-lingui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 10, 2024 9:29am

Copy link

github-actions bot commented Sep 9, 2024

size-limit report 📦

Path Size
./packages/core/dist/index.mjs 2.88 KB (0%)
./packages/detect-locale/dist/index.mjs 723 B (0%)
./packages/react/dist/index.mjs 1.68 KB (0%)
./packages/remote-loader/dist/index.mjs 7.26 KB (0%)

Copy link

codecov bot commented Sep 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.05%. Comparing base (d6b9698) to head (d1efca4).
Report is 56 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2030      +/-   ##
==========================================
+ Coverage   76.65%   80.05%   +3.40%     
==========================================
  Files          81       85       +4     
  Lines        2090     2146      +56     
  Branches      533      548      +15     
==========================================
+ Hits         1602     1718     +116     
- Misses        375      412      +37     
+ Partials      113       16      -97     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@vonovak vonovak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, imho we don't need the same block twice.

packages/core/src/i18n.test.ts Outdated Show resolved Hide resolved
@andrii-bodnar andrii-bodnar merged commit 0ac26cc into lingui:main Sep 11, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpectedly skipped parsing of unicode values inside a string
4 participants