Skip to content

Commit dfff2cd

Browse files
committed
added some tests for undefined or null keys
1 parent 62daae4 commit dfff2cd

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 24.2.0
2+
3+
- feat(typescript): Add strictKeyChecks option to enforce checking key existence when defaultValue is used [2274](https://github.com/i18next/i18next/pull/2274), fixes [2043](https://github.com/i18next/i18next/issues/2043)
4+
15
## 24.1.2
26

37
- optimize fix: Bug Report: Unsafe Behavior in i18n.t Function Leading to Potential Code Execution [2273](https://github.com/i18next/i18next/issues/2273)

test/runtime/i18next.translation.t.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,10 @@ describe('i18next t default returns', () => {
3636
expect(i18n.t('__lookupSetter__')).to.equal('__lookupSetter__');
3737
expect(i18n.t('__proto__')).to.equal('__proto__');
3838
});
39+
40+
it('it should not crash for undefined or null keys', () => {
41+
expect(i18n.t(null)).to.equal('');
42+
expect(i18n.t(undefined)).to.equal('');
43+
expect(i18n.t()).to.equal('');
44+
});
3945
});

test/runtime/translator/translator.exists.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,11 @@ describe('Translator', () => {
7272
expect(t.exists(nullishArg)).toBeFalsy();
7373
});
7474
});
75+
76+
it('it should not crash for undefined or null keys', () => {
77+
expect(t.exists(null)).to.equal(false);
78+
expect(t.exists(undefined)).to.equal(false);
79+
expect(t.exists()).to.equal(false);
80+
});
7581
});
7682
});

0 commit comments

Comments
 (0)