Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix: Check for null values in isDict method #1511

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

Behrouz-B
Copy link
Contributor

This pull request addresses a bug in the isDict method that previously did not explicitly check for null values. The original implementation of the isDict method only checked if the value was an object and not an array.

This behavior is causing some translation values with null values to be converted into an empty object.

Changes made:

  1. Added a null check to the isDict method to ensure that null values are not incorrectly identified as dictionaries.

@zargham-leanix
Copy link

@CodeAndWeb would you be able to review this change? This is blocker for us to update to v16. We have dynamic translations coming from backend, some of them are null values. There are being converted to empty objects now.

@Behrouz-B
Copy link
Contributor Author

@CodeAndWeb would you be able to review this change? This is blocker for us to update to v16. We have dynamic translations coming from backend, some of them are null values. There are being converted to empty objects now.

@ocombe

@CodeAndWeb
Copy link
Member

I've seen the change but had no time yet.
Looks good. I must admit that I had not expected typeof 'null' to be 'object'...

@CodeAndWeb CodeAndWeb merged commit 941c6bc into ngx-translate:master Dec 18, 2024
@zargham-leanix
Copy link

zargham-leanix commented Dec 18, 2024

@CodeAndWeb Andreas, would it be possible to have a minor release for this change?

@CodeAndWeb
Copy link
Member

Possibly tomorrow.

Can you take a look at this additional change?

d31e18b

When passing {a: {aa:"test", bb: "null}}, you would get these values:

  • a => {aa:"test"} the object without the null value
  • a.aa => test
  • a.bb => a.bb (the key)

so the null is removed from the results.

@Behrouz-B
Copy link
Contributor Author

Possibly tomorrow.

Can you take a look at this additional change?

d31e18b

When passing {a: {aa:"test", bb: "null}}, you would get these values:

  • a => {aa:"test"} the object without the null value
  • a.aa => test
  • a.bb => a.bb (the key)

so the null is removed from the results.

Great! Looking forward to it.
The additional changes look good and work well for us.

@CodeAndWeb
Copy link
Member

Done!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants