bin/jobim in jobim-0.4.3 vs bin/jobim in jobim-0.4.4
- old
+ new
@@ -14,13 +14,23 @@
require 'rack'
require 'rack/rewrite'
app = Rack::Builder.new do
use Rack::Rewrite do
- rewrite %r{^(.*)/$}, "$1/index.html", :if => -> (env) {
- env["REQUEST_PATH"][-1,1] == "/" and
- File.exists?(File.join(opts[:Dir], env["REQUEST_PATH"], "index.html"))
- }
+ rewrite %r{(.*)}, -> (match, env) do
+ request_path = env["REQUEST_PATH"]
+
+ return match[1] if opts[:Prefix].length > request_path.length
+
+ local_path = File.join(opts[:Dir], request_path[opts[:Prefix].length..-1])
+
+ if File.directory?(local_path) and
+ File.exists?(File.join(local_path, "index.html"))
+ File.join(request_path, "index.html")
+ else
+ match[1]
+ end
+ end
end
use Rack::CommonLogger, STDOUT
map opts[:Prefix] do