|
@@ -20,7 +20,7 @@ const FileType = {
|
|
* @returns {string}
|
|
* @returns {string}
|
|
*/
|
|
*/
|
|
runDetect: function(input, args) {
|
|
runDetect: function(input, args) {
|
|
- const type = FileType._magicType(input);
|
|
|
|
|
|
+ const type = FileType.magicType(input);
|
|
|
|
|
|
if (!type) {
|
|
if (!type) {
|
|
return "Unknown file type. Have you tried checking the entropy of this data to determine whether it might be encrypted or compressed?";
|
|
return "Unknown file type. Have you tried checking the entropy of this data to determine whether it might be encrypted or compressed?";
|
|
@@ -59,7 +59,7 @@ const FileType = {
|
|
numCommonFound = 0;
|
|
numCommonFound = 0;
|
|
|
|
|
|
for (let i = 0; i < input.length; i++) {
|
|
for (let i = 0; i < input.length; i++) {
|
|
- type = FileType._magicType(input.slice(i));
|
|
|
|
|
|
+ type = FileType.magicType(input.slice(i));
|
|
if (type) {
|
|
if (type) {
|
|
if (ignoreCommon && commonExts.indexOf(type.ext) > -1) {
|
|
if (ignoreCommon && commonExts.indexOf(type.ext) > -1) {
|
|
numCommonFound++;
|
|
numCommonFound++;
|
|
@@ -96,14 +96,13 @@ const FileType = {
|
|
* Given a buffer, detects magic byte sequences at specific positions and returns the
|
|
* Given a buffer, detects magic byte sequences at specific positions and returns the
|
|
* extension and mime type.
|
|
* extension and mime type.
|
|
*
|
|
*
|
|
- * @private
|
|
|
|
* @param {byteArray} buf
|
|
* @param {byteArray} buf
|
|
* @returns {Object} type
|
|
* @returns {Object} type
|
|
* @returns {string} type.ext - File extension
|
|
* @returns {string} type.ext - File extension
|
|
* @returns {string} type.mime - Mime type
|
|
* @returns {string} type.mime - Mime type
|
|
* @returns {string} [type.desc] - Description
|
|
* @returns {string} [type.desc] - Description
|
|
*/
|
|
*/
|
|
- _magicType: function (buf) {
|
|
|
|
|
|
+ magicType: function (buf) {
|
|
if (!(buf && buf.length > 1)) {
|
|
if (!(buf && buf.length > 1)) {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|