<commit_before># frozen_string_literal: true
require 'active_support/concern'

module ResponseSupport
  extend ActiveSupport::Concern

  included do
    def proxy_insecure_urls!(response)
      %w(artwork_url30 artwork_url60 artwork_url100 preview_url).each do |attr|
        url = response[attr]
        next if url.nil?
        next if url.start_with?('https://')
        encrypted_url = encrypt_by_secret_key(url)
        response[attr] = url_for(controller: '/proxies', action: :any, url: encrypted_url)
      end
    end

    def add_affiliate_token_to_view_urls!(response)
      %w(artist_view_url collection_view_url track_view_url).each do |attr|
        url = response[attr]
        next if url.nil?
        new_uri = URI.parse(url)
        new_form_params = URI.decode_www_form(new_uri.query)
        new_form_params << ['at', ENV['ITUNES_AFFILIATE_TOKEN']]
        new_form_params << ['app', 'iTunes']
        new_form_params << ['ct', request.host]
        new_uri.query = URI.encode_www_form(new_form_params)
        response[attr] = new_uri.to_s
      end
    end
  end
end
<commit_msg>Use `%w` or `%W` for an array of words<commit_after># frozen_string_literal: true
require 'active_support/concern'

module ResponseSupport
  extend ActiveSupport::Concern

  included do
    def proxy_insecure_urls!(response)
      %w(artwork_url30 artwork_url60 artwork_url100 preview_url).each do |attr|
        url = response[attr]
        next if url.nil?
        next if url.start_with?('https://')
        encrypted_url = encrypt_by_secret_key(url)
        response[attr] = url_for(controller: '/proxies', action: :any, url: encrypted_url)
      end
    end

    def add_affiliate_token_to_view_urls!(response)
      %w(artist_view_url collection_view_url track_view_url).each do |attr|
        url = response[attr]
        next if url.nil?
        new_uri = URI.parse(url)
        new_form_params = URI.decode_www_form(new_uri.query)
        new_form_params << ['at', ENV['ITUNES_AFFILIATE_TOKEN']]
        new_form_params << %w(app iTunes)
        new_form_params << ['ct', request.host]
        new_uri.query = URI.encode_www_form(new_form_params)
        response[attr] = new_uri.to_s
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.0999099909990999, 'fraction_numerical': 0.0063006300630063005, 'mean_word_length': 3.218216318785579, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, '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': '5206870', 'n_tokens_mistral': 765, 'n_tokens_neox': 750, 'n_words': 150}