mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-14 10:06:58 -04:00
Fixed bug where spaces were causing the text to not be correct
This commit is contained in:
parent
7ca472279c
commit
b156fc9929
1 changed files with 8 additions and 1 deletions
|
@ -33,11 +33,18 @@ class AlternatingCaps extends Operation {
|
|||
*/
|
||||
run(input, args) {
|
||||
let output = "";
|
||||
let previousCaps = true;
|
||||
for (let i = 0; i < input.length; i++) {
|
||||
if (i % 2 === 0) {
|
||||
// Check if the element is a letter
|
||||
if (!RegExp(/^\p{L}/,'u').test(input[i])) {
|
||||
output += input[i];
|
||||
}
|
||||
else if (previousCaps) {
|
||||
output += input[i].toLowerCase();
|
||||
previousCaps = false;
|
||||
} else {
|
||||
output += input[i].toUpperCase();
|
||||
previousCaps = true;
|
||||
}
|
||||
}
|
||||
return output;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue