From 2917d1124a68dae66d5acfbdb9505cd11c548551 Mon Sep 17 00:00:00 2001 From: protonate Date: Thu, 4 May 2017 13:59:08 -0700 Subject: [PATCH] check array length when mapping sizes --- src/sizeMapping.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sizeMapping.js b/src/sizeMapping.js index 46cca5cb668..90ce5b68851 100644 --- a/src/sizeMapping.js +++ b/src/sizeMapping.js @@ -14,7 +14,7 @@ function mapSizes(adUnit) { const mapping = adUnit.sizeMapping.reduce((prev, curr) => { return prev.minWidth < curr.minWidth ? curr : prev; }); - if(mapping.sizes) { + if(mapping.sizes && mapping.sizes.length) { return mapping.sizes; } return adUnit.sizes; @@ -23,7 +23,7 @@ function mapSizes(adUnit) { const mapping = adUnit.sizeMapping.find(sizeMapping =>{ return width > sizeMapping.minWidth; }); - if(mapping && mapping.sizes){ + if(mapping && mapping.sizes && mapping.sizes.length){ sizes = mapping.sizes; utils.logMessage(`AdUnit : ${adUnit.code} resized based on device width to : ${sizes}`); }