diff --git a/spec/helpers_spec.cr b/spec/helpers_spec.cr index ec587bb0..2e38914d 100644 --- a/spec/helpers_spec.cr +++ b/spec/helpers_spec.cr @@ -106,8 +106,14 @@ describe "Macros" do request = HTTP::Request.new("GET", "/") response = call_request_on_app(request) response.status_code.should eq(200) + response.headers["Content-Type"].should eq("application/octet-stream") - response.headers["Content-Length"].should eq("18") + + {% if flag?(:windows) %} + response.headers["Content-Length"].should eq("19") + {% else %} + response.headers["Content-Length"].should eq("18") + {% end %} end it "sends file with given path and given mime-type" do @@ -119,7 +125,12 @@ describe "Macros" do response = call_request_on_app(request) response.status_code.should eq(200) response.headers["Content-Type"].should eq("image/jpeg") - response.headers["Content-Length"].should eq("18") + + {% if flag?(:windows) %} + response.headers["Content-Length"].should eq("19") + {% else %} + response.headers["Content-Length"].should eq("18") + {% end %} end it "sends file with binary stream" do diff --git a/spec/run_spec.cr b/spec/run_spec.cr index a629eac3..c15a7e94 100644 --- a/spec/run_spec.cr +++ b/spec/run_spec.cr @@ -38,8 +38,13 @@ describe "Run" do Kemal.config.env = "test" Kemal.run do |config| server = config.server.not_nil! - server.bind_tcp "127.0.0.1", 3000, reuse_port: true - server.bind_tcp "0.0.0.0", 3001, reuse_port: true + + {% if flag?(:windows) %} + server.bind_tcp "127.0.0.1", 3000 + {% else %} + server.bind_tcp "127.0.0.1", 3000, reuse_port: true + server.bind_tcp "0.0.0.0", 3001, reuse_port: true + {% end %} end CR end diff --git a/spec/view_spec.cr b/spec/view_spec.cr index 79b87687..205f94fa 100644 --- a/spec/view_spec.cr +++ b/spec/view_spec.cr @@ -22,7 +22,11 @@ describe "Views" do end request = HTTP::Request.new("GET", "/view/world") client_response = call_request_on_app(request) - client_response.body.strip.should eq("Hello world\n") + {% if flag?(:windows) %} + client_response.body.strip.should eq("Hello world\r\n") + {% else %} + client_response.body.strip.should eq("Hello world\n") + {% end %} end it "renders layout" do diff --git a/src/kemal/config.cr b/src/kemal/config.cr index f728f57b..c7bc9938 100644 --- a/src/kemal/config.cr +++ b/src/kemal/config.cr @@ -1,5 +1,9 @@ module Kemal - VERSION = {{ `shards version #{__DIR__}`.chomp.stringify }} + {% if flag?(:windows) %} + VERSION = {{ `shards version`.chomp.stringify }} + {% else %} + VERSION = {{ `shards version #{__DIR__}`.chomp.stringify }} + {% end %} # Stores all the configuration options for a Kemal application. # It's a singleton and you can access it like. diff --git a/src/kemal/static_file_handler.cr b/src/kemal/static_file_handler.cr index 4f917669..3b4cf0ec 100644 --- a/src/kemal/static_file_handler.cr +++ b/src/kemal/static_file_handler.cr @@ -27,7 +27,7 @@ module Kemal return end - expanded_path = File.expand_path(request_path, "/") + expanded_path = request_path is_dir_path = if original_path.ends_with?('/') && !expanded_path.ends_with? '/' expanded_path = expanded_path + '/' true