<commit_before>import _ from "lodash";
import React, { Component } from "react";
import Marty from "marty";
import { Link } from 'react-router';
import forms, { Form, RenderForm } from 'newforms';

import FormField from "./formField.jsx";
import ProgressButton from "./progressButton.jsx";

const NewRiderForm = Form.extend({
  first_name: forms.CharField(),
  last_name: forms.CharField(),
  email: forms.EmailField(),
  company: forms.CharField({required: false}),
  website: forms.CharField({required: false}),
  twitter: forms.CharField({required: false}),
  password: forms.CharField({label: "Password", widget: forms.PasswordInput}),
  password_confirm: forms.CharField({label: "Confirm password", widget: forms.PasswordInput}),

  clean: ['password', 'password_confirm', function() {
    if (this.cleanedData.password !== this.cleanedData.password_confirm) {
      let message = "Passwords don't match.";
      this.addError('password_confirm', message);
      throw forms.ValidationError(message);
    }
  }]
});

class Signup extends Component {

  constructor(options) {
    super(options);
    this.state = {
      form: new NewRiderForm({
        data: this.app.authStore.partialUser,
        onChange: this.onFormChange.bind(this)
      })
    };
  }
<commit_msg>Make sure URLs have a protocol before submitting to the server in signup<commit_after>import _ from "lodash";
import React, { Component } from "react";
import Marty from "marty";
import { Link } from 'react-router';
import forms, { Form, RenderForm } from 'newforms';

import FormField from "./formField.jsx";
import ProgressButton from "./progressButton.jsx";

const NewRiderForm = Form.extend({
  first_name: forms.CharField(),
  last_name: forms.CharField(),
  email: forms.EmailField(),
  company: forms.CharField({required: false}),
  website: forms.URLField({required: false}),
  twitter: forms.CharField({required: false}),
  password: forms.CharField({label: "Password", widget: forms.PasswordInput}),
  password_confirm: forms.CharField({label: "Confirm password", widget: forms.PasswordInput}),

  cleanWebsite() {
    // Add a protocol if there isn't already one
    let url =  this.cleanedData.website;
    if (!/^(?:f|ht)tps?\:\/\//.test(url)) {
        url = "http://" + url;
    }
    return url;
  },

  clean() {
    // Check that the passwords match
    if (this.cleanedData.password !== this.cleanedData.password_confirm) {
      let message = "Passwords don't match.";
      this.addError('password_confirm', message);
      throw forms.ValidationError(message);
    }
  }
});

class Signup extends Component {

  constructor(options) {
    super(options);
    this.state = {
      form: new NewRiderForm({
        data: this.app.authStore.partialUser,
        onChange: this.onFormChange.bind(this)
      })
    };
  }

{'fraction_non_alphanumeric': 0.1416903409090909, 'fraction_numerical': 0.0, 'mean_word_length': 3.9334500875656744, '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': '6617847', 'n_tokens_mistral': 848, 'n_tokens_neox': 831, 'n_words': 211}