Skip to content

Commit

Permalink
Bugfix: Issue 3111 (prebid#3122)
Browse files Browse the repository at this point in the history
* bug fix for Prebid issue 3111

* adding try-catch around the fix

* added a warning on exception handling

* updated the message

* using util.deepClone

* changed variable name from original_bid to originalBid

* unit test case for checking original object modification
  • Loading branch information
pm-harshad-mane authored and jsnellbaker committed Sep 26, 2018
1 parent abf9f54 commit 100e3e1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,9 @@ export const spec = {
var dctr = '';
var dctrLen;
var dctrArr = [];
validBidRequests.forEach(bid => {
var bid;
validBidRequests.forEach(originalBid => {
bid = utils.deepClone(originalBid);
_parseAdSlot(bid);
if (bid.params.hasOwnProperty('video')) {
if (!(bid.params.adSlot && bid.params.adUnit && bid.params.adUnitIndex)) {
Expand Down
8 changes: 7 additions & 1 deletion test/spec/modules/pubmaticBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,13 @@ describe('PubMatic adapter', function () {
});

describe('Request formation', function () {
it('Endpoint checking', function () {
it('buildRequests function should not modify original bidRequests object', function () {
let originalBidRequests = utils.deepClone(bidRequests);
let request = spec.buildRequests(bidRequests);
expect(bidRequests).to.deep.equal(originalBidRequests);
});

it('Endpoint checking', function () {
let request = spec.buildRequests(bidRequests);
expect(request.url).to.equal('//hbopenbid.pubmatic.com/translator?source=prebid-client');
expect(request.method).to.equal('POST');
Expand Down

0 comments on commit 100e3e1

Please sign in to comment.