Skip to content

Commit

Permalink
Merge pull request #10 from prebid/cache-path-bugfix
Browse files Browse the repository at this point in the history
Fixed cache path and cache host
  • Loading branch information
Matt Kendall authored Mar 9, 2018
2 parents c2132a9 + ca57db3 commit aab71da
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/creative.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import * as environment from './environment';

const pbjs = window.pbjs = (window.pbjs || {});
const GOOGLE_IFRAME_HOSTNAME = '//tpc.googlesyndication.com';
const DEFAULT_CACHE_HOST = 'prebid.adnxs.com';
const DEFAULT_CACHE_PATH = '/pbc/v1/cache';

/**
* DataObject passed to render the ad
Expand Down Expand Up @@ -118,8 +120,14 @@ function renderCrossDomain(adId, pubUrl) {
requestAdFromPrebid();
}

function renderAmpAd(cacheHost = 'prebid.adnxs.com', cachePath = '/pbc/v1/cache', uuid) {
let adUrl = `https://${cacheHost}${cachePath}?uuid=${uuid}`;
function getCacheEndpoint(cacheHost, cachePath) {
let host = (typeof cacheHost === 'undefined' || cacheHost === "") ? DEFAULT_CACHE_HOST : cacheHost;
let path = (typeof cachePath === 'undefined' || cachePath === "") ? DEFAULT_CACHE_PATH : cachePath;
return `https://${host}${path}`;
}

function renderAmpAd(cacheHost, cachePath, uuid) {
let adUrl = `${getCacheEndpoint(cacheHost, cachePath)}?uuid=${uuid}`;

let handler = function(response) {
let bidObject;
Expand Down

0 comments on commit aab71da

Please # to comment.