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

Switch from Mercel to MiniMime #7

Merged
merged 1 commit into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PATH
remote: .
specs:
fetch-api (0.3.3)
marcel
mini_mime
net-http
rack
singleton
Expand All @@ -12,7 +12,7 @@ GEM
remote: https://rubygems.org/
specs:
diff-lcs (1.5.1)
marcel (1.0.4)
mini_mime (1.1.5)
net-http (0.4.1)
uri
rack (3.1.6)
Expand Down
2 changes: 1 addition & 1 deletion fetch-api.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{\Aexe/}) { File.basename(_1) }
spec.require_paths = ['lib']

spec.add_dependency 'marcel'
spec.add_dependency 'mini_mime'
spec.add_dependency 'net-http'
spec.add_dependency 'rack'
spec.add_dependency 'singleton'
Expand Down
4 changes: 2 additions & 2 deletions lib/fetch/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require_relative 'response'
require_relative 'url_search_params'

require 'marcel'
require 'mini_mime'
require 'net/http'
require 'singleton'
require 'uri'
Expand All @@ -27,7 +27,7 @@ def fetch(resource, method: :get, headers: [], body: nil, redirect: :follow, _re
if v.is_a?(File)
[k, v, {
filename: File.basename(v.path),
content_type: Marcel::MimeType.for(name: v.path)
content_type: MiniMime.lookup_by_filename(v.path)&.content_type || 'application/octet-stream'
}]
else
[k, v]
Expand Down