13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/graphdoc-ruby/static.rb', line 13
def match?(path)
path = ::Rack::Utils.unescape_path(path)
return false unless ::Rack::Utils.valid_path? path
path = ::Rack::Utils.clean_path_info(path)
candidate_paths = [path, "#{path}.html", "#{path}/index.html"]
match = candidate_paths.detect do |candidate_path|
absolute_path = File.join(@root, candidate_path.dup.force_encoding(Encoding::UTF_8))
begin
File.file?(absolute_path) && File.readable?(absolute_path)
rescue SystemCallError
false
end
end
::Rack::Utils.escape_path(match) if match
end
|