Skip to content

Commit

Permalink
URI decode the request path.
Browse files Browse the repository at this point in the history
  • Loading branch information
gdotdesign committed Nov 27, 2024
1 parent 16577e2 commit f4f77b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
7 changes: 5 additions & 2 deletions src/reactor.cr
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,14 @@ module Mint
HTTP::CompressHandler.new,
websocket_handler,
]) do |context|
path =
URI.decode(context.request.path)

# Handle the request depending on the result.
content_type, content =
if file = @files[context.request.path]?
if file = @files[path]?
{
MIME.from_filename?(context.request.path).to_s || "text/plain",
MIME.from_filename?(path).to_s || "text/plain",
file.call,
}
else
Expand Down
11 changes: 6 additions & 5 deletions src/test_runner.cr
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,15 @@ module Mint
end

@server =
HTTP::Server.new([
websocket_handler,
]) do |context|
HTTP::Server.new([websocket_handler]) do |context|
path =
URI.decode(context.request.path)

# Handle the request depending on the result.
content_type, content =
if file = @files[context.request.path]?
if file = @files[path]?
{
MIME.from_filename?(context.request.path).to_s || "text/plain",
MIME.from_filename?(path).to_s || "text/plain",
file.call,
}
else
Expand Down

0 comments on commit f4f77b3

Please sign in to comment.