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
|
# File 'lib/aserto/policy_path_mapper.rb', line 6
def execute(policy_root, request)
method = request.request_method
path = request.path_info
if defined? ::Rails
require_relative "rails/utils"
route = Aserto::Rails::Utils.route(request)
path = route[:path] if route
end
if defined? ::Sinatra
require_relative "sinatra/utils"
route = Aserto::Sinatra::Utils.route(request)
path = route[:path] if route
end
policy_path = "#{policy_root}.#{method}.#{path}"
policy_path.tr!("/", ".")
policy_path.gsub!("..", ".")
policy_path.gsub!(":", "__")
policy_path.gsub!(/[^a-zA-Z0-9._]/, "_")
policy_path.chomp!(".")
policy_path
end
|