Skip to content

Falsy Values Incorrectly Evaluated in Option Checks #354

@momoAmch

Description

@momoAmch

Hello,

I've encountered an issue in multiple functions where certain properties in the options object are checked using a simple if (options.someProp). This causes problems when someProp is a number and equal to 0, as it is treated as false, even though 0 is a valid value.

For example, with Axis cameras, the token of a video encoder can be 0. When calling setVideoEncoderConfiguration, I receive an incorrect response stating that the token is mandatory, even though I provided it. The same issue occurs with other parameters, such as bitrate.

Would it be possible to update these checks to properly handle 0 as a valid value? I’m happy to create a PR, but the fix will require multiple changes across media.js. If you're open to it, I can proceed with the PR.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions