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

Get file extension based on content-type application/javascript #137

Merged
merged 5 commits into from
Sep 12, 2018
Merged
Changes from 1 commit
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
Next Next commit
Get file extension for js resources based on content-type application…
…/javascript
manuelroth committed Sep 11, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 136abb4bb3c24abdeecc578fbfa22d5b2bfb70ec
10 changes: 9 additions & 1 deletion plugins/file/index.js
Original file line number Diff line number Diff line change
@@ -87,7 +87,15 @@ module.exports = {
return Boom.unsupportedMediaType("Content-type not allowed");
}

const type = mimos.type(contentType);
// The mimos package doesn't store the extension for the content-type text/javascript
// because its marked as depricated by IANA. Therefore we get the mimos type based on the
// content-type application/javascript
let type;
if (contentType === "text/javascript") {
type = mimos.type("application/javascript");
} else {
type = mimos.type(contentType);
}
const extension = type.extensions[0] || "";

// buffer the contents to hash and later upload to s3