<commit_before>require 'sinatra/base'

module Sinatra
  module Presence

    def self.registered(app) 
      app.set :local_authority, '127.0.0.1:9292' # http://en.wikipedia.org/wiki/URI_scheme 

      app.get '/local' do
        new_url = request.url.gsub("#{request.host_with_port}", "#{settings.local_authority}")
          .gsub("/local", "") 
        redirect to(new_url)
      end 
    end 

  end 
end<commit_msg>Added cookie to requests for local redirect support<commit_after>require 'sinatra/base'

module Sinatra
  module Presence

    def self.registered(app) 
      app.set :local_authority, '127.0.0.1:9292' # http://en.wikipedia.org/wiki/URI_scheme 

      app.before do
        if(request.cookies["local_url"].nil?)
          new_url = request.url.gsub("#{request.host_with_port}", "#{settings.local_authority}").gsub("/local", "") 
          response.set_cookie(:local_url, value: new_url, expires: Time.now + 600)
        end
      end

      app.get '/local' do
        new_url = request.url.gsub("#{request.host_with_port}", "#{settings.local_authority}").gsub("/local", "") 
        redirect to(new_url)
      end 
    end 

  end 
end
{'fraction_non_alphanumeric': 0.14273356401384082, 'fraction_numerical': 0.019896193771626297, 'mean_word_length': 2.8438538205980066, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '7451400', 'n_tokens_mistral': 411, 'n_tokens_neox': 379, 'n_words': 69}