lib/rail/request.rb in rail-0.0.7 vs lib/rail/request.rb in rail-0.0.8
- old
+ new
@@ -1,17 +1,27 @@
module Rail
class Request
attr_reader :env
def initialize(env)
- @env = env
+ @env = rewrite(env)
end
def path
- @path ||= env['PATH_INFO'].sub(/^\//, '').sub(/\?.*$/, '')
+ env['PATH_INFO']
end
def host
env['HTTP_HOST']
+ end
+
+ private
+
+ def rewrite(env)
+ path = env['PATH_INFO']
+ path = '/index.html' if [nil, '', '/'].include?(path)
+ path = "#{path}.html" if File.extname(path).empty?
+ env['PATH_INFO'] = path
+ env
end
end
end