Fix mounting on "/s3/multipart" not working with Rails

Unlike some other web frameworks like Roda, Rails adds a trailing slash to PATH_INFO when calling mounted apps on root requests. This means that for `POST /s3/multipart`, the Uppy::S3Multipart::App will receive SCRIPT_NAME: "/s3/multipart" PATH_INFO: "/" instead of SCRIPT_NAME: "/s3/multipart" PATH_INFO: "" So we update the app to handle that trailing slash.
parent de569f03
......@@ -32,7 +32,7 @@ module Uppy
route do |r|
# POST /s3/multipart
r.post true do
r.post ["", true] do
content_type = r.params["type"]
filename = r.params["filename"]
......
......@@ -101,6 +101,13 @@ describe Uppy::S3Multipart::App do
assert_equal :create_multipart_upload, @s3.api_requests[0][:operation_name]
assert_equal "public-read", @s3.api_requests[0][:params][:acl]
end
it "works with a trailing slash (for Rails)" do
response = app.post "/s3/multipart/"
assert_equal :create_multipart_upload, @s3.api_requests[0][:operation_name]
assert_match /^\w{32}$/, @s3.api_requests[0][:params][:key]
end
end
describe "GET /s3/multipart/:uploadId" do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment