Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align StaticFileHandler with Crystal's stdlib enabling Windows support #675

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions src/kemal/static_file_handler.cr
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,15 @@
return
end

expanded_path = File.expand_path(request_path, "/")
is_dir_path = if original_path.ends_with?('/') && !expanded_path.ends_with? '/'
expanded_path = expanded_path + '/'
true
else
expanded_path.ends_with? '/'
end
request_path = Path.posix(request_path)
expanded_path = request_path.expand("/")

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)

if request_path != expanded_path
redirect_to context, expanded_path
elsif is_dir && !is_dir_path

Check failure on line 38 in src/kemal/static_file_handler.cr

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, latest)

undefined local variable or method 'is_dir_path' for Kemal::StaticFileHandler

Check failure on line 38 in src/kemal/static_file_handler.cr

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, nightly)

undefined local variable or method 'is_dir_path' for Kemal::StaticFileHandler

Check failure on line 38 in src/kemal/static_file_handler.cr

View workflow job for this annotation

GitHub Actions / test (macos-latest, latest)

undefined local variable or method 'is_dir_path' for Kemal::StaticFileHandler

Check failure on line 38 in src/kemal/static_file_handler.cr

View workflow job for this annotation

GitHub Actions / test (macos-latest, nightly)

undefined local variable or method 'is_dir_path' for Kemal::StaticFileHandler
redirect_to context, expanded_path + '/'
end

Expand Down
Loading