Skip to content

Commit

Permalink
Windows support (#690)
Browse files Browse the repository at this point in the history
Windows support
  • Loading branch information
sdogruyol authored Oct 1, 2024
1 parent 3243b8e commit 85fcbbe
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.cr text eol=lf
*.ecr text eol=lf
47 changes: 41 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,66 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest, macos-latest, windows-latest]
crystal: [latest, nightly]
runs-on: ${{ matrix.os }}

steps:
- name: Install Crystal
uses: oprypin/install-crystal@v1
uses: crystal-lang/install-crystal@v1
with:
crystal: ${{ matrix.crystal }}

- name: Download source
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install dependencies
run: shards install
env:
SHARDS_OPTS: --ignore-crystal-version

- name: Run specs
run: |
crystal spec
crystal spec --release --no-debug
format:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
crystal: [latest, nightly]
runs-on: ${{ matrix.os }}

steps:
- name: Install Crystal
uses: crystal-lang/install-crystal@v1
with:
crystal: ${{ matrix.crystal }}

- name: Download source
uses: actions/checkout@v4

- name: Check formatting
run: crystal tool format --check

ameba:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
crystal: [latest]
runs-on: ${{ matrix.os }}

steps:
- name: Install Crystal
uses: crystal-lang/install-crystal@v1
with:
crystal: ${{ matrix.crystal }}

- name: Download source
uses: actions/checkout@v4

- name: Install dependencies
run: shards install

- name: Run ameba linter
run: bin/ameba

1 change: 1 addition & 0 deletions spec/helpers_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ 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")
end
Expand Down
9 changes: 7 additions & 2 deletions spec/run_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/kemal/config.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Kemal
VERSION = {{ `shards version #{__DIR__}`.chomp.stringify }}
VERSION = {{ `shards version "#{__DIR__}"`.chomp.stringify }}

# Stores all the configuration options for a Kemal application.
# It's a singleton and you can access it like.
Expand Down
2 changes: 1 addition & 1 deletion src/kemal/static_file_handler.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 85fcbbe

Please sign in to comment.