From 07f9f61caf1b91bd7e71b682f7f965fee39ccc23 Mon Sep 17 00:00:00 2001 From: Isaac Good Date: Wed, 8 Jul 2026 00:07:13 -0700 Subject: [PATCH] Update the crypto-square proof to pass with node 24 --- exercises/practice/crypto-square/.meta/proof.ci.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/exercises/practice/crypto-square/.meta/proof.ci.ts b/exercises/practice/crypto-square/.meta/proof.ci.ts index 26d5e0fa4..e46e8a24a 100644 --- a/exercises/practice/crypto-square/.meta/proof.ci.ts +++ b/exercises/practice/crypto-square/.meta/proof.ci.ts @@ -12,11 +12,9 @@ export class Crypto { } const splitRegex = new RegExp(`.{1,${chunkSize}}`, 'g') - return this.ciphertextSegments() - .join('') - .match(splitRegex) - .map((item) => item.padEnd(chunkSize, ' ')) - .join(' ') + const segments = this.ciphertextSegments() ?? [] + const chunks = segments.join('').match(splitRegex) ?? [] + return chunks.map((item) => item.padEnd(chunkSize, ' ')).join(' ') } public get size(): number { @@ -25,7 +23,7 @@ export class Crypto { } private ciphertextSegments(): string[] { - const textSegments = this.plaintextSegments() + const textSegments = this.plaintextSegments() ?? [] const columns: string[][] = [] let i: number let j: number @@ -53,7 +51,7 @@ export class Crypto { return result } - private plaintextSegments(): RegExpMatchArray { + private plaintextSegments(): RegExpMatchArray | null { const plainText = this.plaintext const chunkSize = this.size