100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
# File 'lib/rack/reqorder/route_recognizers.rb', line 100
def grape_recognize_path(path_uri:, rack_app:, options: {})
path_uri = '/' if path_uri.blank?
rack_app.routes.each do |route|
route_options = route.instance_variable_get(:@options)
if route_options[:method] == options[:method] && route_options[:compiled] =~ path_uri
if route_options[:method] == "OPTIONS"
return route_options[:path].
gsub('(.json)', '')
else
return route_options[:path].
gsub(':version', route_options[:version]).
gsub('(.json)', '')
end
end
end
if path_uri.end_with?('.js')
return '/js_asset'
elsif path_uri.end_with?('.css')
return '/css_asset'
elsif path_uri.end_with?('.png', 'jpg')
return '/css_asset'
else
return '/unknown' end
end
|