Skip to content

Commit

Permalink
update to cover some validation and unit tests as requested by harpere
Browse files Browse the repository at this point in the history
  • Loading branch information
renebaudisch committed Oct 1, 2020
1 parent c521bbb commit 2f8d90e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/prebid.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,11 @@ $$PREBID_GLOBAL$$.renderAd = function (doc, id, options) {
bid.adUrl = utils.replaceAuctionPrice(bid.adUrl, bid.cpm);

// replacing clickthrough if submitted
const { clickThrough } = options;
bid.ad = utils.replaceClickThrough(bid.ad, clickThrough);
bid.adUrl = utils.replaceClickThrough(bid.adUrl, clickThrough);
if (options && options.clickThrough) {
const { clickThrough } = options;
bid.ad = utils.replaceClickThrough(bid.ad, clickThrough);
bid.adUrl = utils.replaceClickThrough(bid.adUrl, clickThrough);
}

// save winning bids
auctionManager.addWinningBid(bid);
Expand Down
4 changes: 2 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -719,8 +719,8 @@ export function replaceAuctionPrice(str, cpm) {
}

export function replaceClickThrough(str, clicktag) {
if (!str) return;
return str.replace(/\$\{CLICKTHROUGH\}/g, clicktag);
if (!str || !clicktag || typeof clicktag !== 'string') return;
return str.replace(/\${CLICKTHROUGH}/g, clicktag);
}

export function timestamp() {
Expand Down

0 comments on commit 2f8d90e

Please sign in to comment.