diff --git a/src/tests/test.ts b/src/tests/test.ts index 17e6ec7..78bee85 100644 --- a/src/tests/test.ts +++ b/src/tests/test.ts @@ -229,8 +229,8 @@ describe('email', function() { }); const $ = cheerio.load(html); - assert.equal($('a[href*="survey?token=aaa&answers[QID]=abc"]').length, 1); - assert.equal($('a[href*="survey?token=aaa&answers[QID]=123"]').length, 1); + assert.equal($('a[href*="survey?token=aaa&answers%5BQID%5D=abc"]').length, 1); + assert.equal($('a[href*="survey?token=aaa&answers%5BQID%5D=123"]').length, 1); }); it('should handle custom scale surveys', function() { @@ -252,9 +252,9 @@ describe('email', function() { }); const $ = cheerio.load(html); - assert.equal($('a[href*="survey?token=aaa&answers[QID]=1"]').length, 1); - assert.equal($('a[href*="survey?token=aaa&answers[QID]=2"]').length, 1); - assert.equal($('a[href*="survey?token=aaa&answers[QID]=3"]').length, 1); + assert.equal($('a[href*="survey?token=aaa&answers%5BQID%5D=1"]').length, 1); + assert.equal($('a[href*="survey?token=aaa&answers%5BQID%5D=2"]').length, 1); + assert.equal($('a[href*="survey?token=aaa&answers%5BQID%5D=3"]').length, 1); }); it('should handle odd custom scales', function() { @@ -276,9 +276,9 @@ describe('email', function() { }); const $ = cheerio.load(html); - assert.equal($('a[href*="survey?token=aaa&answers[QID]=-1"]').length, 1); - assert.equal($('a[href*="survey?token=aaa&answers[QID]=-2"]').length, 1); - assert.equal($('a[href*="survey?token=aaa&answers[QID]=-3"]').length, 1); + assert.equal($('a[href*="survey?token=aaa&answers%5BQID%5D=-1"]').length, 1); + assert.equal($('a[href*="survey?token=aaa&answers%5BQID%5D=-2"]').length, 1); + assert.equal($('a[href*="survey?token=aaa&answers%5BQID%5D=-3"]').length, 1); }); it('should include bot-honeypot-link', function() { diff --git a/src/transformV2.ts b/src/transformV2.ts index 4564536..77ac705 100644 --- a/src/transformV2.ts +++ b/src/transformV2.ts @@ -105,7 +105,10 @@ export function transformV2(options: TransformV2Options): TemplateV2Options { if (legacyRatingParameter) { uri.addQueryParam('rating', value); } else { - uri.addQueryParam(`answers[${options.question.id}]`, value); + uri.addQueryParam( + encodeURIComponent(`answers[${options.question.id}]`), + value + ); } }