AT Mot — a bilingual (EN/FR) daily word game native to the AT Protocol.
0

Configure Feed

Select the types of activity you want to include in your feed.

Guard decodeAnswers against empty answer list

decodeAnswers('') returned [''] (length 1) instead of [], breaking the
round-trip for an empty list. This is a latent issue: loadedLangs() in
words.ts treats answers.length > 0 as a real state, so a language shipping
zero answers would be wrongly reported as loaded and dailyAnswer would
return ''. Short-circuit the empty blob to [] and add a regression test.

+5 -1
+1 -1
src/engine/obfuscate.ts
··· 38 38 39 39 /** Decode a blob produced by {@link encodeAnswers} back to the original words. */ 40 40 export function decodeAnswers(blob: string): string[] { 41 - return xor(atob(blob)).split(SEPARATOR); 41 + return blob === '' ? [] : xor(atob(blob)).split(SEPARATOR); 42 42 }
+4
tests/obfuscate.test.ts
··· 12 12 expect(encodeAnswers(sample)).toBe(encodeAnswers(sample)); 13 13 }); 14 14 15 + it('round-trips an empty list back to an empty list (not [""])', () => { 16 + expect(decodeAnswers(encodeAnswers([]))).toEqual([]); 17 + }); 18 + 15 19 it('produces an ASCII base64 string (safe to embed in JSON / a JS bundle)', () => { 16 20 const blob = encodeAnswers(sample); 17 21 expect(typeof blob).toBe('string');