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

Doesn't confirm that the constructor is a function #26

Open
mostekcm opened this issue Mar 25, 2021 · 1 comment
Open

Doesn't confirm that the constructor is a function #26

mostekcm opened this issue Mar 25, 2021 · 1 comment

Comments

@mostekcm
Copy link

I have a plain JS object that is failing the check because it has an attribute called "constructor". But it is defined as a string. This should still be considered a plain JS object.

const myPlainObj = {"code":"invalid_user_password","constructor":"Object","extras":{},"message":"invalid_user_password"};
if (isPlainObject(myPlainObj)) console.log('It is Plain');
else console.log(":(");

https://github.com/jonschlinkert/is-plain-object/blob/master/is-plain-object.js#L17-L19 would likely need to change.

I can create a PR if you'd like.

@mostekcm
Copy link
Author

Okay, I see you have specifically checking for this since pretty much the beginning, and I'm guessing because there are potentially other implications of setting a field called constructor in JSON. Feel free to close this if you'd like. In my use case where I thought I needed this, I have to ignore it anyway because it messes with something else in my framework if you do this.

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

No branches or pull requests

1 participant