Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content.ad: Utilize sourceUrl for validation #6537

Merged
merged 2 commits into from
Dec 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions ads/contentad.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,20 @@ 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 */
const cadApi = 'https://api.content.ad/Scripts/widget2.aspx'
+ '?id=' + encodeURIComponent(global.id)
+ '&d=' + encodeURIComponent(global.d)
+ '&wid=' + global.wid
+ '&url=' + encodeURIComponent(adUrl)
+ '&url=' + encodeURIComponent(sourceUrl)
+ '&cb=' + Date.now();

/* Call Content.ad Widget */
Expand Down
1 change: 1 addition & 0 deletions build-system/amp.extern.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ window.context = {};
window.context.amp3pSentinel;
window.context.clientId;
window.context.initialIntersection;
window.context.sourceUrl;

// Service Holder
window.services;
Expand Down