diff --git a/modules/amxBidAdapter.js b/modules/amxBidAdapter.js index 901e2c508f0..dae7784b3bc 100644 --- a/modules/amxBidAdapter.js +++ b/modules/amxBidAdapter.js @@ -13,19 +13,9 @@ const VAST_RXP = /^\s*<\??(?:vast|xml)/i; const TRACKING_ENDPOINT = 'https://1x1.a-mo.net/hbx/'; const AMUID_KEY = '__amuidpb'; -function getLocation (request) { - const refInfo = request.refererInfo; - if (refInfo == null) { - return parseUrl(location.href); - } - - if (refInfo.isAmp && refInfo.referer != null) { - return parseUrl(refInfo.referer) - } - - const topUrl = refInfo.numIframes > 0 && refInfo.stack[0] != null - ? refInfo.stack[0] : location.href; - return parseUrl(topUrl); +function getLocation(request) { + // TODO: does it make sense to fall back to window.location? + return parseUrl(request.refererInfo?.topmostLocation || window.location.href) }; const largestSize = (sizes, mediaTypes) => { @@ -243,8 +233,9 @@ export const spec = { gs: deepAccess(bidderRequest, 'gdprConsent.gdprApplies', ''), gc: deepAccess(bidderRequest, 'gdprConsent.consentString', ''), u: deepAccess(bidderRequest, 'refererInfo.canonicalUrl', loc.href), + // TODO: are these referer values correct? do: loc.hostname, - re: deepAccess(bidderRequest, 'refererInfo.referer'), + re: deepAccess(bidderRequest, 'refererInfo.ref'), am: getUIDSafe(), usp: bidderRequest.uspConsent || '1---', smt: 1, diff --git a/test/spec/modules/amxBidAdapter_spec.js b/test/spec/modules/amxBidAdapter_spec.js index 48701ce1b60..e6a87d6035e 100644 --- a/test/spec/modules/amxBidAdapter_spec.js +++ b/test/spec/modules/amxBidAdapter_spec.js @@ -40,7 +40,8 @@ const sampleBidderRequest = { auctionId: utils.getUniqueIdentifierStr(), uspConsent: '1YYY', refererInfo: { - referer: 'https://www.prebid.org', + location: 'https://www.prebid.org', + topmostLocation: 'https://www.prebid.org', canonicalUrl: 'https://www.prebid.org/the/link/to/the/page' }, ortb2: sampleFPD @@ -227,35 +228,22 @@ describe('AmxBidAdapter', () => { const { data } = spec.buildRequests([sampleBidRequestBase], { ...sampleBidderRequest, refererInfo: { - numIframes: 1, - referer: 'http://search-traffic-source.com', - stack: [] + location: null, + topmostLocation: null, + ref: 'http://search-traffic-source.com', } }); expect(data.do).to.equal('localhost') expect(data.re).to.equal('http://search-traffic-source.com'); }); - it('if we are in AMP, make sure we use the canonical URL or the referrer (which is sourceUrl)', () => { - const { data } = spec.buildRequests([sampleBidRequestBase], { - ...sampleBidderRequest, - refererInfo: { - isAmp: true, - referer: 'http://real-publisher-site.com/content', - stack: [] - } - }); - expect(data.do).to.equal('real-publisher-site.com') - expect(data.re).to.equal('http://real-publisher-site.com/content'); - }) - it('if prebid is in an iframe, will use the topmost url as domain', () => { const { data } = spec.buildRequests([sampleBidRequestBase], { ...sampleBidderRequest, refererInfo: { - numIframes: 1, - referer: 'http://search-traffic-source.com', - stack: ['http://top-site.com', 'http://iframe.com'] + location: null, + topmostLocation: 'http://top-site.com', + ref: 'http://search-traffic-source.com', } }); expect(data.do).to.equal('top-site.com');