Sha256: d9a8b48ac28c403a2027429c49bbc487ac175d0332dfa1f81fa58453d15af1dc
Contents?: true
Size: 857 Bytes
Versions: 8
Compression:
Stored size: 857 Bytes
Contents
class Rack::App::File::Server def initialize(root_folder, options={}) require 'rack/file' namespace = formatted_namespace(options) namespace.freeze @namespace_rgx = /#{Regexp.escape(namespace)}/.freeze @rack_file_server = ::Rack::File.new(Rack::App::Utils.pwd(root_folder), {}) end def call(env) env[::Rack::PATH_INFO]= clean_path_info(env).sub(@namespace_rgx, '') @rack_file_server.call(env) end protected def raw_namespace(options) options[:to] || '/' end def formatted_namespace(options) namespace = raw_namespace(options).to_s.sub(/^\//, '').sub(/\/$/, '') namespace += '/' unless namespace.empty? namespace end def clean_path_info(env) path_info = ::Rack::Utils.unescape(env[::Rack::PATH_INFO]) return clean_path_info = ::Rack::Utils.clean_path_info(path_info) end end
Version data entries
8 entries across 8 versions & 1 rubygems