Skip to content

Fix: Check for null values in isDict method#1511

Merged
CodeAndWeb merged 1 commit into
ngx-translate:masterfrom
Behrouz-B:bugfix/fix-isDict-method
Dec 18, 2024
Merged

Fix: Check for null values in isDict method#1511
CodeAndWeb merged 1 commit into
ngx-translate:masterfrom
Behrouz-B:bugfix/fix-isDict-method

Conversation

@Behrouz-B

Copy link
Copy Markdown
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-k

Copy link
Copy Markdown

@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
Copy Markdown
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
Copy Markdown
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-k

zargham-k commented Dec 18, 2024

Copy link
Copy Markdown

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

@CodeAndWeb

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

Done!

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

Successfully merging this pull request may close these issues.

3 participants