Skip to content

Commit

Permalink
updated mime
Browse files Browse the repository at this point in the history
  • Loading branch information
ASaiAnudeep committed Oct 23, 2021
1 parent 1bac872 commit ec57861
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "form-data-lite",
"version": "1.0.0",
"version": "1.0.1",
"description": "Module to submit forms and file uploads to other web applications which uses just the standard mime types.",
"main": "src/index.js",
"types": "src/index.d.ts",
Expand All @@ -14,7 +14,7 @@
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-lite": "^1.0.0"
"mime-lite": "^1.0.1"
},
"keywords": [
"form-data",
Expand Down
12 changes: 9 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,12 @@ FormData.prototype._getContentType = function(value, options) {

// or try `name` from formidable, browser
if (!contentType && value.name) {
contentType = mime.getType(value.name);
contentType = getType(value.name);
}

// or try `path` from fs-, request- streams
if (!contentType && value.path) {
contentType = mime.getType(value.path);
contentType = getType(value.path);
}

// or if it's http-reponse
Expand All @@ -263,7 +263,7 @@ FormData.prototype._getContentType = function(value, options) {

// or guess it from the filepath or filename
if (!contentType && (options.filepath || options.filename)) {
contentType = mime.getType(options.filepath || options.filename);
contentType = getType(options.filepath || options.filename);
}

// fallback to the default content type if `value` is not simple value
Expand Down Expand Up @@ -499,3 +499,9 @@ FormData.prototype._error = function(err) {
FormData.prototype.toString = function () {
return '[object FormData]';
};

function getType(value) {
var ct = mime.getType(value);
if (!ct) { console.log("[ERROR] Content-Type not found. Manually set it or update here - https://github.com/ASaiAnudeep/mime-lite") }
return ct;
}

0 comments on commit ec57861

Please sign in to comment.