/usr/lib/ruby/vendor_ruby/merb-core/rack/middleware/path_prefix.rb is in ruby-merb-core 1.1.3+dfsg-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | module Merb
module Rack
class PathPrefix < Merb::Rack::Middleware
# :api: private
def initialize(app, path_prefix = nil)
super(app)
@path_prefix = /^#{Regexp.escape(path_prefix)}/
end
# :api: plugin
def deferred?(env)
strip_path_prefix(env)
@app.deferred?(env)
end
# :api: plugin
def call(env)
strip_path_prefix(env)
@app.call(env)
end
# :api: private
def strip_path_prefix(env)
['PATH_INFO', 'REQUEST_URI'].each do |path_key|
if env[path_key] =~ @path_prefix
env[path_key].sub!(@path_prefix, Merb::Const::EMPTY_STRING)
env[path_key] = Merb::Const::SLASH if env[path_key].empty?
end
end
end
end
end
end
|