Align StaticFileHandler with Crystal's stdlib enabling Windows support

This commit is contained in:
Sijawusz Pur Rahnama 2024-03-16 01:22:51 +01:00 committed by GitHub
parent 7c47bbc150
commit b223199014
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -27,15 +27,10 @@ module Kemal
return return
end end
expanded_path = File.expand_path(request_path, "/") request_path = Path.posix(request_path)
is_dir_path = if original_path.ends_with?('/') && !expanded_path.ends_with? '/' expanded_path = request_path.expand("/")
expanded_path = expanded_path + '/'
true
else
expanded_path.ends_with? '/'
end
file_path = File.join(@public_dir, expanded_path) file_path = @public_dir.join(expanded_path.to_kind(Path::Kind.native))
is_dir = Dir.exists?(file_path) is_dir = Dir.exists?(file_path)
if request_path != expanded_path if request_path != expanded_path