mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 06:55:08 -04:00
Add getDishTitle function
This commit is contained in:
parent
f497dc3170
commit
6ee76e3bf0
5 changed files with 102 additions and 3 deletions
|
@ -141,6 +141,32 @@ class Dish {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the title of the data up to the specified length
|
||||
*
|
||||
* @param {number} maxLength - The maximum title length
|
||||
* @returns {string}
|
||||
*/
|
||||
async getTitle(maxLength) {
|
||||
let title = "";
|
||||
|
||||
// LIST OF FILES - Say e.g. "3 files"
|
||||
switch (this.type) {
|
||||
case Dish.FILE:
|
||||
title = this.value.name;
|
||||
break;
|
||||
case Dish.LIST_FILE:
|
||||
title = `${this.value.length} file(s)`;
|
||||
break;
|
||||
default:
|
||||
title = await this.get("string");
|
||||
}
|
||||
|
||||
title = title.slice(0, maxLength);
|
||||
return title;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Translates the data to the given type format.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue