Skip to content

Commit a87d2f7

Browse files
Remove narrow mime type
1 parent f8b9126 commit a87d2f7

File tree

4 files changed

+6
-13
lines changed

4 files changed

+6
-13
lines changed

app/models/exports/pdf/components/page.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def custom_footer_image
9999
CustomStyle.current.export_footer.present? && CustomStyle.current.export_footer.local_file.present?
100100

101101
image_file = CustomStyle.current.export_footer.local_file.path
102-
content_type = OpenProject::ContentTypeDetector.new(image_file).detect
102+
content_type = OpenProject::ContentTypeDetector.detect(image_file)
103103
return unless pdf_embeddable?(content_type)
104104

105105
image_file

lib/open_project/content_type_detector.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ class ContentTypeDetector
8383
SENSIBLE_DEFAULT = "application/binary"
8484
EMPTY_TYPE = "inode/x-empty"
8585

86+
# Returns a String describing the file's content type
87+
def self.detect(filename)
88+
new(filename).detect
89+
end
90+
8691
def initialize(filename)
8792
@filename = filename
8893
end

lib/open_project/mime_type.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,5 @@ def self.is_type?(type, name)
130130
main_mimetype = main_mimetype_of(name)
131131
type.to_s == main_mimetype
132132
end
133-
134-
def self.narrow_type(name, content_type)
135-
content_type.split("/").first == main_mimetype_of(name) ? of(name) : content_type
136-
end
137133
end
138134
end

spec/lib/open_project/mime_type_spec.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,4 @@
7474
end
7575
end
7676
end
77-
78-
it "equals the main type for the narrow type" do
79-
expect(described_class.narrow_type("rubyfile.rb", "text/plain")).to eq "text/x-ruby"
80-
end
81-
82-
it "uses original type if main type differs" do
83-
expect(described_class.narrow_type("rubyfile.rb", "application/zip")).to eq "application/zip"
84-
end
8577
end

0 commit comments

Comments
 (0)