From 5438f724ac58130261be1e5fc0260c98560bf201 Mon Sep 17 00:00:00 2001 From: Juan Lucero Date: Wed, 7 Dec 2016 15:12:23 -0800 Subject: [PATCH 1/2] Content.ad: Utilize sourceUrl for validation Updated the Content.ad logic to use the sourceUrl value for publisher domain validation. --- ads/contentad.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/ads/contentad.js b/ads/contentad.js index d643ef07e835..8d485fc9b637 100644 --- a/ads/contentad.js +++ b/ads/contentad.js @@ -32,15 +32,12 @@ export function contentad(global, data) { cadDiv.id = 'contentad' + global.wid; window.document.body.appendChild(cadDiv); - /* Capture or pass URL */ - const host = window.context.location.host; - const domain = data.url || window.atob(data.d); - let adUrl = window.context.location.href; - /* Identify and remove CDN path */ - const myreg = new RegExp(':\/\/.*?(?=([a-z0-9\-]+\.?)?' + domain + ')', 'i'); - adUrl = adUrl.replace(myreg, '://'); - if (data.url || !adUrl.includes(domain)) { - adUrl = adUrl.replace(host, domain); + /* Pass Source URL */ + let sourceUrl = window.context.sourceUrl; + if (data.url) { + const host = window.context.location.host; + const domain = data.url || window.atob(data.d); + sourceUrl = sourceUrl.replace(host, domain); } /* Build API URL */ @@ -48,7 +45,7 @@ export function contentad(global, data) { + '?id=' + encodeURIComponent(global.id) + '&d=' + encodeURIComponent(global.d) + '&wid=' + global.wid - + '&url=' + encodeURIComponent(adUrl) + + '&url=' + encodeURIComponent(sourceUrl) + '&cb=' + Date.now(); /* Call Content.ad Widget */ From 84017dcc1a1562697a09f9b42ba03d7b7b84fb30 Mon Sep 17 00:00:00 2001 From: Juan Lucero Date: Thu, 8 Dec 2016 10:27:34 -0800 Subject: [PATCH 2/2] Expose sourceUrl to ads --- build-system/amp.extern.js | 1 + 1 file changed, 1 insertion(+) diff --git a/build-system/amp.extern.js b/build-system/amp.extern.js index b320be0fa5f1..34cdfc33b67b 100644 --- a/build-system/amp.extern.js +++ b/build-system/amp.extern.js @@ -24,6 +24,7 @@ window.context = {}; window.context.amp3pSentinel; window.context.clientId; window.context.initialIntersection; +window.context.sourceUrl; // Service Holder window.services;