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

Fix allowMultipleAds option when resolving wrapper #375

Merged
merged 7 commits into from
Dec 7, 2020

Conversation

ZacharieTFR
Copy link
Contributor

Description

The issue was raised through #371, we can already override the vast value of allowMultipleAds by setting its value inside the option parameter of following public methods:

  • VastClient
  • VastParser

BUT
In the context of a wrapper, when resolving, the allowMultipleAds value defined inside the unwrapped vast was not replaced by the value given in the option. This PR fix it.

Issue

#371

Type

  • Breaking change
  • Enhancement
  • Fix
  • Documentation
  • Tooling

@ZacharieTFR ZacharieTFR added the bug label Nov 4, 2020
@ZacharieTFR ZacharieTFR self-assigned this Nov 4, 2020
Copy link
Contributor

@clementFrancon clementFrancon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A small suggestion otherwise LGTM ;)

Comment on lines 507 to 512
let allowMultipleAds;
if (this.parsingOptions.allowMultipleAds) {
allowMultipleAds = this.parsingOptions.allowMultipleAds;
} else {
allowMultipleAds = ad.allowMultipleAds;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let allowMultipleAds;
if (this.parsingOptions.allowMultipleAds) {
allowMultipleAds = this.parsingOptions.allowMultipleAds;
} else {
allowMultipleAds = ad.allowMultipleAds;
}
const allowMultipleAds = this.parsingOptions.allowMultipleAds || ad.allowMultipleAds

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much cleaner ! ✨

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following my last comment we might want to use ?? (Nullish coalescing) operator

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done !

@@ -117,6 +117,8 @@ By default the fully parsed `VASTResponse` contains all the Ads contained in the
- `urlHandler: URLHandler` - Custom urlhandler to be used instead of the default ones [`urlhandlers`](../../src/urlhandlers)
- `urlhandler: URLHandler` - Fulfills the same purpose as `urlHandler`, which is the preferred parameter to use
- `resolveAll: Boolean` - Allows you to parse all the ads contained in the VAST or to parse them ad by ad or adPod by adPod (default `true`)
- `allowMultipleAds: Boolean` - A Boolean value that identifies whether multiple ads are allowed in the requested VAST response. This will override any value of allowMultipleAds attribute set in the VAST
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the doc is misleading, it says it will override any value of allowMultipleAds attribute set in the VAST but actually if I pass allowMultipleAds: false to it and the VAST has allowMultipleAds set to true, we will take the one from the VAST

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, we do want to replace any vast value if allowMultipleAds was provided in the option. Considering the null coalescing operator it will do so 👍

@clementFrancon
Copy link
Contributor

LGTM 🥇

Comment on lines +161 to +168
withCredentials: options.withCredentials,
};

this.maxWrapperDepth = options.wrapperLimit || DEFAULT_MAX_WRAPPER_DEPTH;
this.parentURLs = [];
this.parsingOptions = { allowMultipleAds: options.allowMultipleAds };
this.remainingAds = [];
this.rootErrorURLTemplates = [];
this.rootURL = '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why this re order is need? or was it generate by prettier 2.0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no real need, I just thought it would be more readable 🤷‍♂️

@ZacharieTFR ZacharieTFR merged commit b6cb644 into master Dec 7, 2020
@ZacharieTFR ZacharieTFR deleted the allowMultipleAds-config branch December 7, 2020 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

3 participants