Skip to content

Commit 2ef8eaf

Browse files
committed
convert bidders: amx
1 parent fafb541 commit 2ef8eaf

File tree

2 files changed

+13
-34
lines changed

2 files changed

+13
-34
lines changed

modules/amxBidAdapter.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,9 @@ const VAST_RXP = /^\s*<\??(?:vast|xml)/i;
1313
const TRACKING_ENDPOINT = 'https://1x1.a-mo.net/hbx/';
1414
const AMUID_KEY = '__amuidpb';
1515

16-
function getLocation (request) {
17-
const refInfo = request.refererInfo;
18-
if (refInfo == null) {
19-
return parseUrl(location.href);
20-
}
21-
22-
if (refInfo.isAmp && refInfo.referer != null) {
23-
return parseUrl(refInfo.referer)
24-
}
25-
26-
const topUrl = refInfo.numIframes > 0 && refInfo.stack[0] != null
27-
? refInfo.stack[0] : location.href;
28-
return parseUrl(topUrl);
16+
function getLocation(request) {
17+
// TODO: does it make sense to fall back to window.location?
18+
return parseUrl(request.refererInfo?.topmostLocation || window.location.href)
2919
};
3020

3121
const largestSize = (sizes, mediaTypes) => {
@@ -243,8 +233,9 @@ export const spec = {
243233
gs: deepAccess(bidderRequest, 'gdprConsent.gdprApplies', ''),
244234
gc: deepAccess(bidderRequest, 'gdprConsent.consentString', ''),
245235
u: deepAccess(bidderRequest, 'refererInfo.canonicalUrl', loc.href),
236+
// TODO: are these referer values correct?
246237
do: loc.hostname,
247-
re: deepAccess(bidderRequest, 'refererInfo.referer'),
238+
re: deepAccess(bidderRequest, 'refererInfo.ref'),
248239
am: getUIDSafe(),
249240
usp: bidderRequest.uspConsent || '1---',
250241
smt: 1,

test/spec/modules/amxBidAdapter_spec.js

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ const sampleBidderRequest = {
4040
auctionId: utils.getUniqueIdentifierStr(),
4141
uspConsent: '1YYY',
4242
refererInfo: {
43-
referer: 'https://www.prebid.org',
43+
location: 'https://www.prebid.org',
44+
topmostLocation: 'https://www.prebid.org',
4445
canonicalUrl: 'https://www.prebid.org/the/link/to/the/page'
4546
},
4647
ortb2: sampleFPD
@@ -227,35 +228,22 @@ describe('AmxBidAdapter', () => {
227228
const { data } = spec.buildRequests([sampleBidRequestBase], {
228229
...sampleBidderRequest,
229230
refererInfo: {
230-
numIframes: 1,
231-
referer: 'http://search-traffic-source.com',
232-
stack: []
231+
location: null,
232+
topmostLocation: null,
233+
ref: 'http://search-traffic-source.com',
233234
}
234235
});
235236
expect(data.do).to.equal('localhost')
236237
expect(data.re).to.equal('http://search-traffic-source.com');
237238
});
238239

239-
it('if we are in AMP, make sure we use the canonical URL or the referrer (which is sourceUrl)', () => {
240-
const { data } = spec.buildRequests([sampleBidRequestBase], {
241-
...sampleBidderRequest,
242-
refererInfo: {
243-
isAmp: true,
244-
referer: 'http://real-publisher-site.com/content',
245-
stack: []
246-
}
247-
});
248-
expect(data.do).to.equal('real-publisher-site.com')
249-
expect(data.re).to.equal('http://real-publisher-site.com/content');
250-
})
251-
252240
it('if prebid is in an iframe, will use the topmost url as domain', () => {
253241
const { data } = spec.buildRequests([sampleBidRequestBase], {
254242
...sampleBidderRequest,
255243
refererInfo: {
256-
numIframes: 1,
257-
referer: 'http://search-traffic-source.com',
258-
stack: ['http://top-site.com', 'http://iframe.com']
244+
location: null,
245+
topmostLocation: 'http://top-site.com',
246+
ref: 'http://search-traffic-source.com',
259247
}
260248
});
261249
expect(data.do).to.equal('top-site.com');

0 commit comments

Comments
 (0)