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
Detect extname from Content-Type #7733
Conversation
app/models/concerns/remotable.rb
Outdated
@@ -24,14 +24,16 @@ def remotable_attachment(attachment_name, limit) | |||
Request.new(:get, url).perform do |response| | |||
next if response.code != 200 | |||
|
|||
matches = response.headers['content-disposition']&.match(/filename="([^"]*)"/) | |||
filename = matches.nil? ? parsed_url.path.split('/').last : matches[1] | |||
content_type = response.headers['content-type']&.split(/\s*;\s*/).first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not chain ordinary method call after safe navigation operator.
app/models/concerns/remotable.rb
Outdated
matches = response.headers['content-disposition']&.match(/filename="([^"]*)"/) | ||
filename = matches.nil? ? parsed_url.path.split('/').last : matches[1] | ||
content_type = response.headers['content-type']&.split(/\s*;\s*/).first | ||
extname = MIME::Types[content_type].first&.extensions.first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not chain ordinary method call after safe navigation operator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
857407a 💫
oops |
CI passed |
failed cases
https://cdn.example.com/v1/media.png;compress=true
https://embed.example.com/decorate.php?illust_id=68957437