Giter Site home page Giter Site logo

ObjectID.isValid should check that `typeof toString === 'function'` otherwise if it's not an object and doesn't have a `toString` then it would return false about bson-objectid HOT 5 CLOSED

cabinjs avatar cabinjs commented on July 19, 2024
ObjectID.isValid should check that `typeof toString === 'function'` otherwise if it's not an object and doesn't have a `toString` then it would return false

from bson-objectid.

Comments (5)

niftylettuce avatar niftylettuce commented on July 19, 2024

e.g. if you pass an empty plain object to ObjectID.isValid it throws an uncaught exception.

from bson-objectid.

niftylettuce avatar niftylettuce commented on July 19, 2024

Specifically https://github.com/williamkapke/bson-objectid/blob/master/objectid.js#L98 should change to if (!objectid || (typeof objectid !== 'string' && (typeof objectid !== 'object' || typeof objectid.toString !== 'function')))

from bson-objectid.

williamkapke avatar williamkapke commented on July 19, 2024

seems right. I'm happy to take a PR for it!

from bson-objectid.

niftylettuce avatar niftylettuce commented on July 19, 2024

roger, PR inbound

from bson-objectid.

niftylettuce avatar niftylettuce commented on July 19, 2024

@williamkapke see #28, I also added a test case as well.

let me know of any issues, or when a new version is published to npm.

thanks many! 👍

from bson-objectid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.