<commit_before>/* eslint-disable no-underscore-dangle */
import Vue from 'vue';
import VueRouter from 'vue-router';

import RouteHandler from '../../RouteHandler.vue';
import TopForm from './TopForm.vue';
import mergeValuesIntoStartState from '../../utils/merge-values-into-start-state';
import sanitizeParams from '../../utils/sanitize-params';
import { BASE_FORM_STATE, AMBASSADOR_CODES } from './constants';

/* import Thermometer from './Thermometer.vue'; */

Vue.use(VueRouter);

function createInitialFormState(queryParams) {
  // if form submission was invalid,
  // rehydrate the store from the JSON blob in the template
  if (window.__BASE_FORM_REHYDRATION__) {
    return mergeValuesIntoStartState(
      BASE_FORM_STATE,
      window.__BASE_FORM_REHYDRATION__
    );
  }

  const cleanParams = sanitizeParams(queryParams);
  const {
    campaignId = '',
    referralId = '',
    firstName = '',
    lastName = '',
    email = '',
    zipcode = '',
    code = '',
  } = cleanParams;
  let amount;
  let installmentPeriod;

  if (code) {
    ({ amount, installmentPeriod } = AMBASSADOR_CODES[code]);
  } else {
    ({ amount, installmentPeriod = 'monthly' } = cleanParams);

    switch (installmentPeriod.toLowerCase()) {
      case 'once':
        installmentPeriod = 'None';
        amount = amount || '60';
        break;
      case 'monthly':
        amount = amount || '35';
        break;<commit_msg>protect against bad code param<commit_after>/* eslint-disable no-underscore-dangle */
import Vue from 'vue';
import VueRouter from 'vue-router';

import RouteHandler from '../../RouteHandler.vue';
import TopForm from './TopForm.vue';
import mergeValuesIntoStartState from '../../utils/merge-values-into-start-state';
import sanitizeParams from '../../utils/sanitize-params';
import { BASE_FORM_STATE, AMBASSADOR_CODES } from './constants';

/* import Thermometer from './Thermometer.vue'; */

Vue.use(VueRouter);

function createInitialFormState(queryParams) {
  // if form submission was invalid,
  // rehydrate the store from the JSON blob in the template
  if (window.__BASE_FORM_REHYDRATION__) {
    return mergeValuesIntoStartState(
      BASE_FORM_STATE,
      window.__BASE_FORM_REHYDRATION__
    );
  }

  const cleanParams = sanitizeParams(queryParams);
  const {
    campaignId = '',
    referralId = '',
    firstName = '',
    lastName = '',
    email = '',
    zipcode = '',
    code = '',
  } = cleanParams;
  let amount;
  let installmentPeriod;

  if (code && AMBASSADOR_CODES[code]) {
    ({ amount, installmentPeriod } = AMBASSADOR_CODES[code]);
  } else {
    ({ amount, installmentPeriod = 'monthly' } = cleanParams);

    switch (installmentPeriod.toLowerCase()) {
      case 'once':
        installmentPeriod = 'None';
        amount = amount || '60';
        break;
      case 'monthly':
        amount = amount || '35';
        break;
{'fraction_non_alphanumeric': 0.1336581970066133, 'fraction_numerical': 0.0027845457709711106, 'mean_word_length': 3.2202643171806167, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3814911', 'n_tokens_mistral': 881, 'n_tokens_neox': 873, 'n_words': 208}