Skip to content

Commit

Permalink
Updated characters in leet speak transformer
Browse files Browse the repository at this point in the history
  • Loading branch information
rion18 committed Aug 28, 2024
1 parent b5a3d6a commit fd19424
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/transformer/resolve-leetspeak/dictionary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ export const dictionary = new Map([
['a', '@4'],
['c', '('],
['e', '3'],
['i', '1|'],
['i', '1|!'],
['g', '6'],
['o', '0'],
['s', '$'],
['s', '$5'],
['t', '7'],
['z', '2'],
]);
13 changes: 12 additions & 1 deletion test/transformer/resolve-leetspeak/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,23 @@ describe('resolveLeetSpeakTransformer()', () => {
it('should remap relevant characters to their normalized equivalent', () => {
const transformer = resolveLeetSpeakTransformer();
expect(transformer.transform('@'.charCodeAt(0))).toBe(CharacterCode.LowerA);
expect(transformer.transform('4'.charCodeAt(0))).toBe(CharacterCode.LowerA);
expect(transformer.transform('('.charCodeAt(0))).toBe('c'.charCodeAt(0));
expect(transformer.transform('3'.charCodeAt(0))).toBe('e'.charCodeAt(0));
expect(transformer.transform('1'.charCodeAt(0))).toBe('i'.charCodeAt(0));
expect(transformer.transform('!'.charCodeAt(0))).toBe('i'.charCodeAt(0));
expect(transformer.transform('|'.charCodeAt(0))).toBe('i'.charCodeAt(0));
expect(transformer.transform('6'.charCodeAt(0))).toBe('g'.charCodeAt(0));
expect(transformer.transform('0'.charCodeAt(0))).toBe('o'.charCodeAt(0));
expect(transformer.transform('$'.charCodeAt(0))).toBe('s'.charCodeAt(0));
expect(transformer.transform('5'.charCodeAt(0))).toBe('s'.charCodeAt(0));
expect(transformer.transform('7'.charCodeAt(0))).toBe('t'.charCodeAt(0));
expect(transformer.transform('2'.charCodeAt(0))).toBe(CharacterCode.LowerZ);
});

it('should leave other characters as is', () => {
const transformer = resolveLeetSpeakTransformer();
expect(transformer.transform('e'.charCodeAt(0))).toBe('e'.charCodeAt(0));
expect(transformer.transform('f'.charCodeAt(0))).toBe('f'.charCodeAt(0));
expect(transformer.transform(CharacterCode.Backslash)).toBe(CharacterCode.Backslash);
});
});
Expand Down

0 comments on commit fd19424

Please sign in to comment.