<commit_before># frozen_string_literal: true

class UrlValidator < ActiveModel::EachValidator
  def validate_each(record, attribute, value)
    return if value.blank?
    begin
      uri = URI.parse(value)
      resp = uri.is_a?(URI::HTTP)
    rescue URI::InvalidURIError
      resp = false
    end

    return unless resp == true

    record.errors[attribute] << (options[:message] || 'is not an url')
  end
end<commit_msg>Fix UriValidator's validation<commit_after># frozen_string_literal: true

class UrlValidator < ActiveModel::EachValidator
  def validate_each(record, attribute, value)
    return if value.blank?
    begin
      uri = URI.parse(value)
      resp = uri.is_a?(URI::HTTP)
    rescue URI::InvalidURIError
      resp = false
    end

    return if resp == true

    record.errors[attribute] << (options[:message] || 'is not an url')
  end
end
{'fraction_non_alphanumeric': 0.10348837209302325, 'fraction_numerical': 0.0, 'mean_word_length': 3.507853403141361, 'pattern_counts': {'":': 0, '<': 9, '<?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': '6414692', 'n_tokens_mistral': 261, 'n_tokens_neox': 258, 'n_words': 71}