From 268ab353eece58cbf7a44bb872d19a7188e0f6fc Mon Sep 17 00:00:00 2001 From: Vladimir Gorej Date: Wed, 5 Jun 2024 09:17:59 +0200 Subject: [PATCH] test(substitute): add test for not encoding [ and ] characters Refs #2 --- test/substitute.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/substitute.js b/test/substitute.js index 46ed6cf..19c0d64 100644 --- a/test/substitute.js +++ b/test/substitute.js @@ -38,6 +38,12 @@ describe('substitute', function () { assert.equal(result, '/pets/%2F%3F%23'); }); + it('should avoid encoding "[" and "]" characters using encodeURIComponent', function () { + const result = substitute('/pets/{petId}', { petId: '[]' }); + + assert.equal(result, '/pets/[]'); + }); + it('should substitute server variable with empty value', function () { const result = substitute('/pets/{petId}/test', { petId: '' });