mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-22 07:46:16 -04:00
Added 'isImage' and 'isType' functions
This commit is contained in:
parent
f355fe3447
commit
f4f9b5c91c
6 changed files with 130 additions and 105 deletions
|
@ -9,7 +9,7 @@ import { fromHex } from "../lib/Hex";
|
|||
import Operation from "../Operation";
|
||||
import OperationError from "../errors/OperationError";
|
||||
import Utils from "../Utils";
|
||||
import { detectFileType } from "../lib/FileType";
|
||||
import { isType, detectFileType } from "../lib/FileType";
|
||||
|
||||
/**
|
||||
* PlayMedia operation
|
||||
|
@ -66,8 +66,7 @@ class PlayMedia extends Operation {
|
|||
|
||||
|
||||
// Determine file type
|
||||
const types = detectFileType(input);
|
||||
if (!(types && types.length && /^audio|video/.test(types[0].mime))) {
|
||||
if (!isType(/^(audio|video)/, input)) {
|
||||
throw new OperationError("Invalid or unrecognised file type");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue