From eee31c293bc107334ac2ac7704dc44d1f1c43863 Mon Sep 17 00:00:00 2001 From: evanweaver Date: Sun, 28 Oct 2007 14:43:47 +0000 Subject: dir handler was all messed up (Clifford Heath) git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@817 19e92222-5c0b-0410-8929-a290d50e31e9 --- lib/mongrel/handlers.rb | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'lib/mongrel') diff --git a/lib/mongrel/handlers.rb b/lib/mongrel/handlers.rb index 385f958..499d69f 100644 --- a/lib/mongrel/handlers.rb +++ b/lib/mongrel/handlers.rb @@ -126,29 +126,27 @@ module Mongrel def can_serve(path_info) req_path = HttpRequest.unescape(path_info) - if @path - req_path = File.expand_path(File.join(@path, path_info), @path) - else - req_path = File.expand_path(req_path) - end - - if req_path.index(@path) == 0 and File.exist? req_path - # it exists and it's in the right location + # Add the drive letter or root path + req_path = File.join(@path, req_path) if @path + req_path = File.expand_path req_path + + if File.exist? req_path + # It exists and it's in the right location if File.directory? req_path - # the request is for a directory + # The request is for a directory index = File.join(req_path, @index_html) if File.exist? index - # serve the index + # Serve the index return index elsif @listing_allowed - # serve the directory + # Serve the directory return req_path else - # do not serve anything + # Do not serve anything return nil end else - # it's a file and it's there + # It's a file and it's there return req_path end else -- cgit v1.2.3-24-ge0c7