Skip to content

Conversation

@BrianHuf
Copy link
Contributor

avoid exception if JSON object happens to have a hasOwnProperty key

@marcolink marcolink requested a review from Copilot October 28, 2025 18:31
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a potential runtime exception that could occur when JSON objects contain a property named hasOwnProperty. The code now uses Object.prototype.hasOwnProperty.call() instead of the unsafe instance method to safely check property existence.

Key Changes:

  • Replaced all instances of object.hasOwnProperty(key) with Object.prototype.hasOwnProperty.call(object, key) to safely handle objects with hasOwnProperty as a key
  • Added test data including an object with hasOwnProperty property to validate the fix

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/index.ts Updated all hasOwnProperty checks to use safe Object.prototype.hasOwnProperty.call() pattern
src/index.spec.ts Added test object with hasOwnProperty key to validate the fix

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@marcolink marcolink changed the title fix object with hasOwnProperty key fix: object with hasOwnProperty key Oct 28, 2025
@marcolink
Copy link
Owner

Thanks for your contribution @BrianHuf

@marcolink marcolink merged commit 93ad8e2 into marcolink:main Oct 28, 2025
2 checks passed
marcolink pushed a commit that referenced this pull request Oct 28, 2025
## [1.2.5](v1.2.4...v1.2.5) (2025-10-28)

### Bug Fixes

* object with hasOwnProperty key ([#15](#15)) ([93ad8e2](93ad8e2))
@marcolink
Copy link
Owner

🎉 This PR is included in version 1.2.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants