<commit_before>class ProxyController < ApplicationController
      include ReverseProxy::Controller

  skip_authorization_check
  skip_before_action :verify_authenticity_token

  def index
    path = params[:path]
    if path.blank?
      return render(
        json: { message: "Not found" },
        status: 404,
      )
    end

    path = path.gsub(/(https?):\/([^\/])/, "\\1://\\2")

    # Whitelist
    if !path.start_with?("https://maps.googleapis.com/maps/api")
      return render(
        json: { message: "Not found" },
        status: 404,
      )
    end

    reverse_proxy path, path: ""
  end<commit_msg>Add query parameters to proxy<commit_after>class ProxyController < ApplicationController
      include ReverseProxy::Controller

  skip_authorization_check
  skip_before_action :verify_authenticity_token

  def index
    path = params[:path]
    if path.blank?
      return render(
        json: { message: "Not found" },
        status: 404,
      )
    end

    path = path.gsub(/(https?):\/([^\/])/, "\\1://\\2")

    # Whitelist
    if !path.start_with?("https://maps.googleapis.com/maps/api")
      Rails.logger.warn{"Proxy path not white-listed: #{path}"}
      return render(
        json: { message: "Not found" },
        status: 404,
      )
    end

    Rails.logger.debug{"Proxying: #{path}"}

    p = params.to_unsafe_hash.dup.except(:controller, :action, :path)
    if p.size > 0
      path = "#{path}?#{p.to_query}"
      Rails.logger.debug{"Updating path: #{path}"}
    end

    reverse_proxy path, path: ""
  end
{'fraction_non_alphanumeric': 0.14276485788113696, 'fraction_numerical': 0.010981912144702842, 'mean_word_length': 2.552752293577982, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 2, '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': '651633', 'n_tokens_mistral': 520, 'n_tokens_neox': 487, 'n_words': 107}