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: use safe property checks #521

Merged
merged 6 commits into from
Aug 26, 2023
Merged

fix: use safe property checks #521

merged 6 commits into from
Aug 26, 2023

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Aug 26, 2023

πŸ”— Linked issue

Ref unjs/nitro#1637

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

in operator expects the right hand to be an Object and can easily lead to edge case issues when we check something like 'foo' in 2 > Uncaught TypeError: Cannot use 'in' operator to search for 'foo' in 2.

This PR uses a small shared util for safer checks.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@codecov
Copy link

codecov bot commented Aug 26, 2023

Codecov Report

Merging #521 (27082e4) into main (164f68e) will increase coverage by 0.03%.
The diff coverage is 90.32%.

@@            Coverage Diff             @@
##             main     #521      +/-   ##
==========================================
+ Coverage   82.11%   82.15%   +0.03%     
==========================================
  Files          31       32       +1     
  Lines        3646     3665      +19     
  Branches      536      543       +7     
==========================================
+ Hits         2994     3011      +17     
- Misses        652      654       +2     
Files Changed Coverage Ξ”
src/event/event.ts 86.71% <50.00%> (+0.10%) ⬆️
src/utils/internal/object.ts 75.00% <75.00%> (ΓΈ)
src/error.ts 80.55% <100.00%> (+0.10%) ⬆️
src/event/utils.ts 58.62% <100.00%> (+0.23%) ⬆️
src/utils/body.ts 94.57% <100.00%> (+0.02%) ⬆️
src/utils/response.ts 78.67% <100.00%> (+0.42%) ⬆️

@pi0 pi0 merged commit 706f73f into main Aug 26, 2023
6 checks passed
@pi0 pi0 deleted the fix/in-operator branch August 26, 2023 18:57
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.

None yet

1 participant