lib/frank/statik.rb in frank-0.2.0 vs lib/frank/statik.rb in frank-0.2.1
- old
+ new
@@ -11,19 +11,29 @@
# handles serving from __frank__
# looks for static access, if not found,
# passes request to frank
def call(env)
- path = env['PATH_INFO']
+ path = env['PATH_INFO'].dup
if path.include? '__frank__'
env['PATH_INFO'].gsub!('/__frank__', '')
result = @frank_server.call(env)
- elsif path.index('/') == 0
+ else
+ env['PATH_INFO'] << '/' unless path.match(/(\.\w+|\/)$/)
+ env['PATH_INFO'] << 'index.html' if path[-1..-1] == '/'
result = @static_server.call(env)
end
- return result if result[0] == 200
- @app.call(env)
+
+ # return if static assets found
+ # else reset the path and pass to frank
+ if result[0] == 200
+ result
+ else
+ env['PATH_INFO'] = path
+ @app.call(env)
+ end
+
end
end
end
\ No newline at end of file