Skip to content

Commit

Permalink
馃悰Fix subdomain handling in idealmedia widgets (ampproject#24579)
Browse files Browse the repository at this point in the history
* Fix subdomain handling in idealmedia widgets

* Fix subdomain handling in idealmedia widgets

* Fix subdomain handling in idealmedia widgets

* Fix subdomain handling in idealmedia widgets

* Fix subdomain handling in idealmedia widgets
  • Loading branch information
velichkin authored and joshuarrrr committed Oct 22, 2019
1 parent 100c785 commit 96c6d53
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions ads/idealmedia.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,18 @@ export function idealmedia(global, data) {

document.body.appendChild(scriptRoot);

/**
* Returns path for provided js filename
* @param {string} publisher The first number.
* @return {string} Path to provided filename.
*/
function getResourceFilePath(publisher) {
const publisherStr = publisher.replace(/[^A-z0-9]/g, '');
return `${publisherStr[0]}/${publisherStr[1]}`;
}

const url =
`https://jsc.idealmedia.io/${encodeURIComponent(data.publisher[0])}/` +
`${encodeURIComponent(data.publisher[1])}/` +
`https://jsc.idealmedia.io/${getResourceFilePath(data.publisher)}/` +
`${encodeURIComponent(data.publisher)}.` +
`${encodeURIComponent(data.widget)}.js?t=` +
Math.floor(Date.now() / 36e5);
Expand Down

0 comments on commit 96c6d53

Please sign in to comment.