<commit_before>pageflow.UrlInputView = Backbone.Marionette.Layout.extend({
  mixins: [pageflow.inputView],

  template: 'pageflow/ui/templates/inputs/url_input',

  ui: {
    input: 'input',
    validation: '.validation'
  },

  events: {
    'change': 'onChange'
  },

  onRender: function() {
    this.ui.validation.hide();
    this.load();
    this.validate();
  },

  onChange: function() {
    var view = this;

    this.saveDisplayProperty();

    this.validate().done(function() {
      view.save();
    });
  },

  saveDisplayProperty: function() {
    this.model.set(this.options.displayPropertyName, this.ui.input.val());
    this.model.unset(this.options.propertyName);
  },

  save: function() {
    var view = this;

    $.when(this.transformPropertyValue(this.ui.input.val())).then(function(value) {
      view.model.set(view.options.propertyName, value);
    });
  },

  load: function() {
    this.ui.input.val(this.model.get(this.options.displayPropertyName));
    this.onLoad();
  },

  /**
   * Override to be notified when the input has been loaded.
   */
  onLoad: function() {},

  /**
   * Override to validate the untransformed url. Validation error
   * message can be passed as rejected promise. Progress notifications
   * are displayed. Only valid urls are stored in the configuration.
   *
   * @return Promise
   */
  validateUrl: function(url) {
    return $.Deferred().resolve().promise();
  },

  /**
   * Override to transform the property value before it is stored.
   *
   * @return Promise | String
   */
  transformPropertyValue: function(value) {
    return value;
  },

  /**
   * Override to change the list of supported host names.
   */
  supportedHosts: function() {
    return this.options.supportedHosts;
  },

  validate: function(success) {
    var view = this;
    var options = this.options;
    var value = this.ui.input.val();

    if (options.required && !value) {
      displayValidationError('Muss ausgefüllt werden.');
    }
    else if (value && !isValidUrl(value)) {
      displayValidationError('URL muss mit http:// beginnen.');
    }
    else if (value && !hasSupportedHost(value)) {
      displayValidationError('Es werden nur die folgenden Anbieter unterstützt:' +
                             _.map(view.supportedHosts(), function(url) {
                               return '<li>' + url +'</li>';
                             }).join(''));
    }
    else {
      return view.validateUrl(value)
        .progress(function(message) {
          displayValidationPending(message);
        })
        .done(function() {
          resetValidationError();
        })
        .fail(function(error) {
          displayValidationError(error);
        });
    }

    return $.Deferred().reject().promise();

    function isValidUrl(url) {
      return url.match(/^http:\/\//i);
    }

    function hasSupportedHost(url) {
      return _.any(view.supportedHosts(), function(host) {
        return url.match(new RegExp('^' + host));
      });
    }

    function displayValidationError(message) {
      view.$el.addClass('invalid');<commit_msg>allow secure hypertext transfer protocol<commit_after>pageflow.UrlInputView = Backbone.Marionette.Layout.extend({
  mixins: [pageflow.inputView],

  template: 'pageflow/ui/templates/inputs/url_input',

  ui: {
    input: 'input',
    validation: '.validation'
  },

  events: {
    'change': 'onChange'
  },

  onRender: function() {
    this.ui.validation.hide();
    this.load();
    this.validate();
  },

  onChange: function() {
    var view = this;

    this.saveDisplayProperty();

    this.validate().done(function() {
      view.save();
    });
  },

  saveDisplayProperty: function() {
    this.model.set(this.options.displayPropertyName, this.ui.input.val());
    this.model.unset(this.options.propertyName);
  },

  save: function() {
    var view = this;

    $.when(this.transformPropertyValue(this.ui.input.val())).then(function(value) {
      view.model.set(view.options.propertyName, value);
    });
  },

  load: function() {
    this.ui.input.val(this.model.get(this.options.displayPropertyName));
    this.onLoad();
  },

  /**
   * Override to be notified when the input has been loaded.
   */
  onLoad: function() {},

  /**
   * Override to validate the untransformed url. Validation error
   * message can be passed as rejected promise. Progress notifications
   * are displayed. Only valid urls are stored in the configuration.
   *
   * @return Promise
   */
  validateUrl: function(url) {
    return $.Deferred().resolve().promise();
  },

  /**
   * Override to transform the property value before it is stored.
   *
   * @return Promise | String
   */
  transformPropertyValue: function(value) {
    return value;
  },

  /**
   * Override to change the list of supported host names.
   */
  supportedHosts: function() {
    return this.options.supportedHosts;
  },

  validate: function(success) {
    var view = this;
    var options = this.options;
    var value = this.ui.input.val();

    if (options.required && !value) {
      displayValidationError('Muss ausgefüllt werden.');
    }
    else if (value && !isValidUrl(value)) {
      displayValidationError('URL muss mit http:// oder https:// beginnen.');
    }
    else if (value && !hasSupportedHost(value)) {
      displayValidationError('Es werden nur die folgenden Anbieter unterstützt:' +
                             _.map(view.supportedHosts(), function(url) {
                               return '<li>' + url +'</li>';
                             }).join(''));
    }
    else {
      return view.validateUrl(value)
        .progress(function(message) {
          displayValidationPending(message);
        })
        .done(function() {
          resetValidationError();
        })
        .fail(function(error) {
          displayValidationError(error);
        });
    }

    return $.Deferred().reject().promise();

    function isValidUrl(url) {
      return url.match(/^https?:\/\//i);
    }

    function hasSupportedHost(url) {
      return _.any(view.supportedHosts(), function(host) {
        return url.match(new RegExp('^' + host));
      });
    }

    function displayValidationError(message) {
      view.$el.addClass('invalid');
{'fraction_non_alphanumeric': 0.143658810325477, 'fraction_numerical': 0.0, 'mean_word_length': 2.5666094911377932, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 1, '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': '5628614', 'n_tokens_mistral': 1854, 'n_tokens_neox': 1815, 'n_words': 385}