Skip to content

Commit 8673fc6

Browse files
jsnellbakerdluxemburg
authored andcommitted
initial commit to fix issue prebid#2291 (prebid#2308)
1 parent 61b5371 commit 8673fc6

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

modules/dfpAdServerVideo.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export default function buildDfpVideoUrl(options) {
7070
if (options.url) {
7171
// when both `url` and `params` are given, parsed url will be overwriten
7272
// with any matching param components
73-
urlComponents = parse(options.url);
73+
urlComponents = parse(options.url, {noDecodeWholeURL: true});
7474

7575
if (isEmpty(options.params)) {
7676
return buildUrlFromAdserverUrlComponents(urlComponents, bid);
@@ -126,7 +126,8 @@ function buildUrlFromAdserverUrlComponents(components, bid) {
126126
const customParams = Object.assign({},
127127
adserverTargeting,
128128
);
129-
components.search.cust_params = encodeURIComponent(formatQS(customParams));
129+
const encodedCustomParams = encodeURIComponent(formatQS(customParams));
130+
components.search.cust_params = (components.search.cust_params) ? components.search.cust_params + '%26' + encodedCustomParams : encodedCustomParams;
130131

131132
return buildUrl(components);
132133
}

test/spec/modules/dfpAdServerVideo_spec.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,26 @@ describe('The DFP video support module', () => {
130130
expect(customParams).to.have.property('my_targeting', 'foo');
131131
});
132132

133+
it('should merge the user-provided cust-params with the default ones when using url object', () => {
134+
const bidCopy = Object.assign({ }, bid);
135+
bidCopy.adserverTargeting = {
136+
hb_adid: 'ad_id',
137+
};
138+
139+
const url = parse(buildDfpVideoUrl({
140+
adUnit: adUnit,
141+
bid: bidCopy,
142+
url: 'https://video.adserver.example/ads?sz=640x480&iu=/123/aduniturl&impl=s&cust_params=section%3dblog%26mykey%3dmyvalue'
143+
}));
144+
145+
const queryObject = parseQS(url.query);
146+
const customParams = parseQS('?' + decodeURIComponent(queryObject.cust_params));
147+
148+
expect(customParams).to.have.property('hb_adid', 'ad_id');
149+
expect(customParams).to.have.property('section', 'blog');
150+
expect(customParams).to.have.property('mykey', 'myvalue');
151+
});
152+
133153
it('should not overwrite an existing description_url for object input and cache disabled', () => {
134154
const bidCopy = Object.assign({}, bid);
135155
bidCopy.vastUrl = 'vastUrl.example';

0 commit comments

Comments
 (0)