diff --git a/src/utils.js b/src/utils.js index 38ab6d88e12..88328ff10aa 100644 --- a/src/utils.js +++ b/src/utils.js @@ -111,7 +111,14 @@ export function tryAppendQueryString(existingUrl, key, value) { // parse a query string object passed in bid params // bid params should be an object such as {key: "value", key1 : "value1"} // aliases to formatQS -export let parseQueryStringParameters = internal.formatQS; +export function parseQueryStringParameters(queryObj) { + let result = ''; + for (var k in queryObj) { + if (queryObj.hasOwnProperty(k)) { result += k + '=' + encodeURIComponent(queryObj[k]) + '&'; } + } + result = result.replace(/&$/, ''); + return result; +} // transform an AdServer targeting bids into a query string to send to the adserver export function transformAdServerTargetingObj(targeting) { diff --git a/test/spec/utils_spec.js b/test/spec/utils_spec.js index 96df3cf996c..4dbb40557af 100644 --- a/test/spec/utils_spec.js +++ b/test/spec/utils_spec.js @@ -63,12 +63,12 @@ describe('Utils', function () { describe('parseQueryStringParameters', function () { it('should append query string to existing using the input obj', function () { var obj = { - a: '1', - b: '2' + a: 'http://example.com/?foo=bar&bar=foo', + b: 'abc["def"]' }; var output = utils.parseQueryStringParameters(obj); - var expectedResult = 'a=' + encodeURIComponent('1') + '&b=' + encodeURIComponent('2'); + var expectedResult = 'a=' + encodeURIComponent('http://example.com/?foo=bar&bar=foo') + '&b=' + encodeURIComponent('abc["def"]'); assert.equal(output, expectedResult); });