<commit_before>require 'cgi'

module LinkBack
  extend ActiveSupport::Concern

  included do
    after_filter 'save_link_back', only: [:new, :edit]
  end

  def save_link_back
    # session[:previous_url] is a Rails built-in variable to save last url.
    if request.format == Mime::HTML
      referer_uri = request.referer ? URI.parse(request.referer) : nil
      referer_params = referer_uri && referer_uri.query ? CGI::parse(referer_uri.query) : nil
      if referer_uri && params['back']
        session[:link_back] = referer_uri.path
      elsif !(referer_uri && referer_params && referer_params['back'])
        session.delete(:link_back)
      end
    end
  end

  def link_back
    session.delete(:link_back)
  end
end<commit_msg>link back, make concern content private<commit_after>require 'cgi'

module LinkBack
  extend ActiveSupport::Concern

  included do
    after_filter 'save_link_back', only: [:new, :edit]
  end

  private
    def save_link_back
      # session[:previous_url] is a Rails built-in variable to save last url.
      if request.format == Mime::HTML
        referer_uri = request.referer ? URI.parse(request.referer) : nil
        referer_params = referer_uri && referer_uri.query ? CGI::parse(referer_uri.query) : nil
        if referer_uri && params['back']
          session[:link_back] = referer_uri.path
        elsif !(referer_uri && referer_params && referer_params['back'])
          session.delete(:link_back)
        end
      end
    end

    def link_back
      session.delete(:link_back)
    end
end
{'fraction_non_alphanumeric': 0.09922178988326848, 'fraction_numerical': 0.0, 'mean_word_length': 3.2273972602739724, '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': '3088671', 'n_tokens_mistral': 498, 'n_tokens_neox': 499, 'n_words': 117}