Changeset 2281


Ignore:
Timestamp:
Aug 1, 2012, 12:43:13 AM (9 years ago)
Author:
glasgall
Message:
Replace Rack::PathInfoRewriter with ScriptNameRewriter, which just strips public/dispatch.fcgi out of SCRIPT_NAME so that Rails generates correct URLs
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/locker-dev/locker/deploy/bin/rails

    r2280 r2281  
    161161Thread.abort_on_exception = true
    162162
    163 class Rack::PathInfoRewriter
     163# Strip public/dispatch.fcgi out of SCRIPT_NAME so Rails generates nicer URLs
     164class ScriptNameRewriter
     165 
    164166  def initialize(app)
    165167    \@app = app
     
    167169
    168170  def call(env)
    169     env["SCRIPT_NAME"] = ""
    170     parts = env['REQUEST_URI'].split('?')
    171     env['PATH_INFO'] = parts[0]
    172     env['QUERY_STRING'] = parts[1].to_s
     171    if env['SCRIPT_NAME'] =~ /dispatch\.fcgi/
     172      env['SCRIPT_NAME'].gsub!(/public\\/dispatch\.fcgi/,'')
     173    end
    173174    \@app.call(env)
    174175  end
     
    180181
    181182  begin
    182     Rack::Handler::FastCGI.run Rack::PathInfoRewriter.new(Rack::URLMap.new("/$appdir" => ${appclass}::Application,
    183                                                                            "/" => ${appclass}::Application))
     183    Rack::Handler::FastCGI.run ScriptNameRewriter.new(Rack::URLMap.new("/" => ${appclass}::Application))
    184184  rescue => e
    185185   dispatch_logger.error(e)
Note: See TracChangeset for help on using the changeset viewer.