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

Detect extname from Content-Type #7733

Merged
merged 1 commit into from Jun 4, 2018
Merged

Detect extname from Content-Type #7733

merged 1 commit into from Jun 4, 2018

Conversation

ykzts
Copy link
Sponsor Member

@ykzts ykzts commented Jun 4, 2018

failed cases

  • https://cdn.example.com/v1/media.png;compress=true
  • https://embed.example.com/decorate.php?illust_id=68957437

@ykzts ykzts added the bug Something isn't working label Jun 4, 2018
@@ -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
Copy link
Member

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.

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
Copy link
Member

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.

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

857407a 💫

@ykzts
Copy link
Sponsor Member Author

ykzts commented Jun 4, 2018

oops

@ykzts
Copy link
Sponsor Member Author

ykzts commented Jun 4, 2018

CI passed

@Gargron Gargron merged commit dc73241 into mastodon:master Jun 4, 2018
@ykzts ykzts deleted the content-type branch June 4, 2018 22:09
lawremipsum pushed a commit to lawremipsum/mspsocial-mastodon that referenced this pull request Jul 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants