Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Roll back breaking change to utils.parseQueryStringParameters #5230

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
@@ -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) {
6 changes: 3 additions & 3 deletions test/spec/utils_spec.js
Original file line number Diff line number Diff line change
@@ -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);
});