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

Allow variant to be overridden from URL fragment #4127

Merged
merged 2 commits into from Jul 20, 2016

Conversation

lannka
Copy link
Contributor

@lannka lannka commented Jul 19, 2016

#1411

A re-try to address comments in #4079

@@ -34,6 +36,12 @@ export function allocateVariant(win, experimentName, config) {
assertName(experimentName);
validateConfig(config);

// Variant can be overridden from URL fragment.
const override = viewerFor(win).getParam(ATTR_PREFIX + experimentName);
if (override && config.variants.hasOwnProperty(override)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

For stronger safety, I suggest doing this in getVariantOverride_() so invalid values never make it to the overrides map to start with.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I don't quite understand. Are you suggesting to extract a method named getVariantOverride_()? Why would that be safer?

Copy link
Contributor

Choose a reason for hiding this comment

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

sorry this comment was based on the code in #4079. I see that PR is closed. This is fine, ignore my previous comment.

@aghassemi
Copy link
Contributor

LGTM

@lannka
Copy link
Contributor Author

lannka commented Jul 20, 2016

Comment addressed. PTAL

@jridgewell
Copy link
Contributor

LGTM.

@lannka lannka merged commit 2d6c31d into ampproject:master Jul 20, 2016
@lannka lannka deleted the variant_override branch July 20, 2016 17:32
ariangibson pushed a commit to Mixpo/amphtml that referenced this pull request Sep 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants