Skip to content

Commit

Permalink
Ensure width and height are integers (#3674)
Browse files Browse the repository at this point in the history
* Ensure width and height are integers

Some bidders (like OpenX) return bid responses with width and height as strings. Let's follow the docs and ensure that they indeed are integers, avoiding some strict comparison surprises.

* lint

* typo

* Update bidderFactory.js

* Update bidderFactory.js

* Update bidderFactory.js
  • Loading branch information
benjaminclot authored and jaiminpanchal27 committed Mar 26, 2019
1 parent e74bf6c commit cce5b6e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/adapters/bidderFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,9 @@ export function getIabSubCategory(bidderCode, category) {

// check that the bid has a width and height set
function validBidSize(adUnitCode, bid, bidRequests) {
if ((bid.width || bid.width === 0) && (bid.height || bid.height === 0)) {
if ((bid.width || parseInt(bid.width, 10) === 0) && (bid.height || parseInt(bid.height, 10) === 0)) {
bid.width = parseInt(bid.width, 10);
bid.height = parseInt(bid.height, 10);
return true;
}

Expand All @@ -432,8 +434,8 @@ function validBidSize(adUnitCode, bid, bidRequests) {
// response that does not explicitly set width or height
if (parsedSizes.length === 1) {
const [ width, height ] = parsedSizes[0].split('x');
bid.width = width;
bid.height = height;
bid.width = parseInt(width, 10);
bid.height = parseInt(height, 10);
return true;
}

Expand Down

0 comments on commit cce5b6e

Please sign in to comment.