Comparing version 6.2.3 to 6.2.4
17
index.js
@@ -14,2 +14,3 @@ 'use strict'; | ||
const pEvent = require('p-event'); | ||
const fileType = require('file-type'); | ||
@@ -19,3 +20,3 @@ const fsP = pify(fs); | ||
const getFilename = res => { | ||
const getFilename = (res, data) => { | ||
const header = res.headers['content-disposition']; | ||
@@ -31,3 +32,13 @@ | ||
return filenameFromPath(res); | ||
let filename = filenameFromPath(res); | ||
if (!path.extname(filename)) { | ||
const type = fileType(data); | ||
if (type) { | ||
filename = `${filename}.${type.ext}`; | ||
} | ||
} | ||
return filename; | ||
}; | ||
@@ -67,3 +78,3 @@ | ||
const filename = opts.filename || filenamify(getFilename(res)); | ||
const filename = opts.filename || filenamify(getFilename(res, data)); | ||
const outputFilepath = path.join(output, filename); | ||
@@ -70,0 +81,0 @@ |
{ | ||
"name": "download", | ||
"version": "6.2.3", | ||
"version": "6.2.4", | ||
"description": "Download and extract files", | ||
@@ -32,2 +32,3 @@ "license": "MIT", | ||
"decompress": "^4.0.0", | ||
"file-type": "5.2.0", | ||
"filenamify": "^2.0.0", | ||
@@ -34,0 +35,0 @@ "get-stream": "^3.0.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5973
71
10
+ Addedfile-type@5.2.0