Skip to content

Commit

Permalink
Refactored to use site.page
Browse files Browse the repository at this point in the history
  • Loading branch information
yuki-arasaki committed Apr 8, 2023
1 parent dd24af0 commit b294306
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 3 additions & 3 deletions modules/pubxBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { deepSetValue } from '../src/utils.js';
import { deepSetValue, deepAccess } from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';

const BIDDER_CODE = 'pubx';
Expand All @@ -15,9 +15,9 @@ export const spec = {
return validBidRequests.map(bidRequest => {
const bidId = bidRequest.bidId;
const params = bidRequest.params;
const pageUrl = location.href.replace(/\?.*$/, '');
const pageEnc = encodeURIComponent(pageUrl);
const sid = params.sid;
const pageUrl = deepAccess(bidRequest, 'ortb2.site.page').replace(/\?.*$/, '');
const pageEnc = encodeURIComponent(pageUrl);
const payload = {
sid: sid,
pu: pageEnc
Expand Down
9 changes: 8 additions & 1 deletion test/spec/modules/pubxBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,21 @@ describe('pubxAdapter', function () {
id: '26c1ee0038ac11',
params: {
sid: '12345abc'
},
ortb2: {
site: {
page: `${location.href}?test=1`
}
}
}
];

const data = {
banner: {
sid: '12345abc',
pu: encodeURIComponent(location.href.replace(/\?.*$/, '')),
pu: encodeURIComponent(
utils.deepAccess(bidRequests[0], 'ortb2.site.page').replace(/\?.*$/, '')
),
},
};

Expand Down

0 comments on commit b294306

Please sign in to comment.