From ce40c522c77d7fd2a5fd06c9fd853a4e3989cdee Mon Sep 17 00:00:00 2001 From: Nik 'Fire Eater' Krimm Date: Tue, 26 Oct 2021 09:34:08 -0500 Subject: [PATCH] [488] Fixes => form-urlencoded requests do not proxy correctly if content-type contains a semi-colon. --- app/steps/sendProxyRequest.js | 2 +- test/getBody.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/steps/sendProxyRequest.js b/app/steps/sendProxyRequest.js index 6764ecfb..0efbca74 100644 --- a/app/steps/sendProxyRequest.js +++ b/app/steps/sendProxyRequest.js @@ -50,7 +50,7 @@ function sendProxyRequest(Container) { if (bodyContent.length) { var body = bodyContent; var contentType = proxyReq.getHeader('Content-Type'); - if (contentType === 'x-www-form-urlencoded' || contentType === 'application/x-www-form-urlencoded') { + if (contentType && contentType.match(/x-www-form-urlencoded/)) { try { var params = JSON.parse(body); body = Object.keys(params).map(function(k) { return k + '=' + params[k]; }).join('&'); diff --git a/test/getBody.js b/test/getBody.js index 7ef58bfe..75a6e89c 100644 --- a/test/getBody.js +++ b/test/getBody.js @@ -30,6 +30,7 @@ describe('when proxy request is a GET', function () { var testCases = [ { name: 'form encoded', encoding: 'application/x-www-form-urlencoded' }, + { name: 'form encoded with charset', encoding: 'application/x-www-form-urlencoded; charset=UTF-8' }, // #488 { name: 'JSON encoded', encoding: 'application/json' } ];