# File lib/mini_profiler/profiler.rb, line 573
    def get_profile_script(env)
      path = if ENV["PASSENGER_BASE_URI"] then
        # added because the SCRIPT_NAME workaround below then
        # breaks running under a prefix as permitted by Passenger. 
        "#{ENV['PASSENGER_BASE_URI']}#{@config.base_url_path}"
      elsif env["action_controller.instance"]
        # Rails engines break SCRIPT_NAME; the following appears to discard SCRIPT_NAME
        # since url_for appears documented to return any String argument unmodified
        env["action_controller.instance"].url_for("#{@config.base_url_path}")
      else
        "#{env['RACK_MINI_PROFILER_ORIGINAL_SCRIPT_NAME']}#{@config.base_url_path}"
      end

      settings = {
       :path            => path,
       :version         => MiniProfiler::ASSET_VERSION,
       :position        => @config.position,
       :showTrivial     => false,
       :showChildren    => false,
       :maxTracesToShow => 10,
       :showControls    => false,
       :authorized      => true,
       :toggleShortcut  => @config.toggle_shortcut,
       :startHidden     => @config.start_hidden,
       :collapseResults => @config.collapse_results
      }

      if current && current.page_struct
        settings[:ids]       = ids_comma_separated(env)
        settings[:currentId] = current.page_struct[:id]
      else
        settings[:ids]       = []
        settings[:currentId] = ""
      end

      # TODO : cache this snippet
      script = IO.read(::File.expand_path('../html/profile_handler.js', ::File.dirname(__FILE__)))
      # replace the variables
      settings.each do |k,v|
        regex = Regexp.new("\\{#{k.to_s}\\}")
        script.gsub!(regex, v.to_s)
      end

      current.inject_js = false if current
      script
    end