From cc499682a75bec35483dda534ae8c37203b98a0d Mon Sep 17 00:00:00 2001 From: Hans Date: Sun, 13 Aug 2023 14:23:41 +0800 Subject: [PATCH] Add more test --- __tests__/index.mjs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/__tests__/index.mjs b/__tests__/index.mjs index 00410de..924cd87 100644 --- a/__tests__/index.mjs +++ b/__tests__/index.mjs @@ -36,9 +36,21 @@ describe('parse', () => { }) }) + it('mix array & object', () => { + chai.expect(parse('a[a][][a]&a[a][a]&a[a][][b]')).to.be.deep.equal({ + a: { a: { 0: { a: '' }, a: '', 2:{ b: '' } } }, + }) + }) + it('drop insecure key', () => { chai.expect(parse('a[constructor][prototype][a]=1')).to.be.deep.equal({ a: undefined, }) + chai.expect(parse('a[toString]=1')).to.be.deep.equal({ + a: undefined, + }) + chai.expect(parse('a[__proto__]=1')).to.be.deep.equal({ + a: undefined, + }) }) })