Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DFP Ad Server Video: bugfix - encode description url #10575

Merged
merged 3 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions modules/dfpAdServerVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ export function buildAdpodVideoUrl({code, params, callback} = {}) {
*/
function buildUrlFromAdserverUrlComponents(components, bid, options) {
const descriptionUrl = getDescriptionUrl(bid, components, 'search');
if (descriptionUrl) { components.search.description_url = descriptionUrl; }
if (descriptionUrl) {
components.search.description_url = descriptionUrl;
}

components.search.cust_params = getCustParams(bid, options, components.search.cust_params);
return buildUrl(components);
Expand All @@ -264,7 +266,7 @@ function buildUrlFromAdserverUrlComponents(components, bid, options) {
* @return {string | undefined} The encoded vast url if it exists, or undefined
*/
function getDescriptionUrl(bid, components, prop) {
return deepAccess(components, `${prop}.description_url`) || dep.ri().page;
return deepAccess(components, `${prop}.description_url`) || encodeURIComponent(dep.ri().page);
}

/**
Expand Down
14 changes: 12 additions & 2 deletions test/spec/modules/dfpAdServerVideo_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,18 @@ describe('The DFP video support module', function () {
}, options)));
const prm = utils.parseQS(url.query);
expect(prm.description_url).to.eql('example.com');
})
})
});

it('should use a URI encoded page location as default for description_url', () => {
sandbox.stub(dep, 'ri').callsFake(() => ({page: 'https://example.com?iu=/99999999/news&cust_params=current_hour%3D12%26newscat%3Dtravel&pbjs_debug=true'}));
const url = parse(buildDfpVideoUrl(Object.assign({
adUnit: adUnit,
bid: bid,
}, options)));
const prm = utils.parseQS(url.query);
expect(prm.description_url).to.eql('https%3A%2F%2Fexample.com%3Fiu%3D%2F99999999%2Fnews%26cust_params%3Dcurrent_hour%253D12%2526newscat%253Dtravel%26pbjs_debug%3Dtrue');
});
});
})

it('should make a legal request URL when given the required params', function () {
Expand Down