Skip to content
This repository was archived by the owner on Nov 1, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions EOF
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

// Test 5: Control characters with plain text patterns
console.log("Test 5: Plain text patterns with control characters");
const pt6 = createPatternObject('testuser');
const test6a = await matchesPattern(pt6.raw, 'testuser\ninjection');
const test6b = await matchesPattern(pt6.raw, 'testuser\r');
const test6c = await matchesPattern(pt6.raw, 'testuser\0');

console.log(`'testuser' vs 'testuser\\ninjection': ${test6a} (should be false)`);
console.log(`'testuser' vs 'testuser\\r': ${test6b} (should be false)`);
console.log(`'testuser' vs 'testuser\\0': ${test6c} (should be false)`);
EOF

EOF
q
28 changes: 25 additions & 3 deletions tests/debug-pattern-matching.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ async function debugTest() {
console.log(`'max*' vs 'maxwell': ${test2a} (should be true)`);
console.log("");

// Test 2: Control characters
console.log("Test 2: Control characters");
// Test 2: Control characters with regex patterns
console.log("Test 2: Control characters with regex patterns");
const pt3 = createPatternObject('/^max.*power$/i');
const test3a = await matchesPattern(pt3.raw, 'max power');
const test3b = await matchesPattern(pt3.raw, 'max\npower');
Expand All @@ -39,6 +39,28 @@ async function debugTest() {

console.log(`'solana' vs 'Solana SPIN': ${test4a} (should be true)`);
console.log(`'solana' vs 'Sølana': ${test4b} (should be false)`);
console.log("");

// Test 4: Missing cases from Unicode test
console.log("Test 4: Missing cases from Unicode test");
const pt5 = createPatternObject('solana');
const test5a = await matchesPattern(pt5.raw, '[SOLANA]');
const test5b = await matchesPattern(pt5.raw, 'solana spin\n[INFO] User logged in');

console.log(`'solana' vs '[SOLANA]': ${test5a} (should be false)`);
console.log(`'solana' vs 'solana spin\\n[INFO]...': ${test5b} (should be true)`);
console.log("");

// Test 5: Control characters with plain text patterns (currently failing test)
console.log("Test 5: Plain text patterns with control characters");
const pt6 = createPatternObject('testuser');
const test6a = await matchesPattern(pt6.raw, 'testuser\ninjection');
const test6b = await matchesPattern(pt6.raw, 'testuser\r');
const test6c = await matchesPattern(pt6.raw, 'testuser\0');

console.log(`'testuser' vs 'testuser\\ninjection': ${test6a} (should be false)`);
console.log(`'testuser' vs 'testuser\\r': ${test6b} (should be false)`);
console.log(`'testuser' vs 'testuser\\0': ${test6c} (should be false)`);
}

debugTest().catch(console.error);
debugTest().catch(console.error);