FIX: best effort at returning correct mime types in manifest.json

This commit is contained in:
Jeff Wong
2018-05-17 12:10:35 -07:00
parent 53f8f6095d
commit 41ffafb65e
2 changed files with 22 additions and 1 deletions

View File

@ -30,7 +30,7 @@ class MetadataController < ApplicationController
{
src: logo,
sizes: "512x512",
type: "image/png"
type: guess_mime(logo)
}
]
}
@ -49,4 +49,11 @@ class MetadataController < ApplicationController
manifest
end
def guess_mime(filename)
extension = filename.split(".").last
valid_image_mimes = { png: "image/png", jpg: "image/jpeg", jpeg: "image/jpeg", gif: "image/gif", ico: "image/x-icon" }
valid_image_mimes[extension.to_sym] || "image/png"
end
end