CyberChef/src/node/apiUtils.mjs

34 lines
733 B
JavaScript
Raw Normal View History

2018-04-20 13:23:20 +02:00
/**
2018-07-06 13:54:19 +02:00
* Utility functions for the node environment
2018-04-20 13:23:20 +02:00
*
* @author d98762625 [d98762625@gmail.com]
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
2018-06-19 17:41:16 +02:00
/**
* SomeName => someName
* @param {String} name - string to be altered
* @returns {String} decapitalised
*/
export function decapitalise(name) {
// Don't decapitalise names that start with 2+ caps
if (/^[A-Z0-9]{2,}/g.test(name)) {
return name;
}
// reserved. Don't change for now.
if (name === "Return") {
return name;
}
return `${name.charAt(0).toLowerCase()}${name.substr(1)}`;
}
2018-04-20 13:23:20 +02:00
/**
2018-07-20 14:59:52 +02:00
* Remove spaces, make lower case.
* @param str
2018-04-20 13:23:20 +02:00
*/
2018-07-06 13:54:19 +02:00
export function sanitise(str) {
return str.replace(/ /g, "").toLowerCase();
2018-04-20 13:23:20 +02:00
}