Fix filtering to work on all the data and not just the result snippet

This commit is contained in:
j433866 2018-12-18 11:55:49 +00:00
parent 283d7f2159
commit 367d79e820

View file

@ -276,17 +276,18 @@ class Magic {
let results = []; let results = [];
// Record the properties of the current data // Record the properties of the current data
results.push({ if (filter == null || new RegExp(filter).test(this.inputStr)){
recipe: recipeConfig, results.push({
data: this.inputStr.slice(0, 100), recipe: recipeConfig,
languageScores: this.detectLanguage(extLang), data: this.inputStr.slice(0, 100),
fileType: this.detectFileType(), languageScores: this.detectLanguage(extLang),
isUTF8: this.isUTF8(), fileType: this.detectFileType(),
entropy: this.calcEntropy(), isUTF8: this.isUTF8(),
matchingOps: matchingOps, entropy: this.calcEntropy(),
useful: useful matchingOps: matchingOps,
}); useful: useful
});
}
const prevOp = recipeConfig[recipeConfig.length - 1]; const prevOp = recipeConfig[recipeConfig.length - 1];
// Execute each of the matching operations, then recursively call the speculativeExecution() // Execute each of the matching operations, then recursively call the speculativeExecution()
@ -331,10 +332,7 @@ class Magic {
r.fileType || // A file was found r.fileType || // A file was found
r.isUTF8 || // UTF-8 was found r.isUTF8 || // UTF-8 was found
r.matchingOps.length // A matching op was found r.matchingOps.length // A matching op was found
) && )
(
filter == null || // Either no filter was passed, or
new RegExp(filter).test(r.data)) // the filter matches the result data
); );
// Return a sorted list of possible recipes along with their properties // Return a sorted list of possible recipes along with their properties