mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-03-30 13:43:26 +08:00
fix: calendar-accurate date validation in parseSessionFilename, add 22 tests
- Fix parseSessionFilename to reject impossible dates (Feb 31, Apr 31, Feb 29 non-leap) using Date constructor month/day roundtrip check - Add 6 session-manager tests for calendar date validation edge cases - Add 3 session-manager tests for code blocks/special chars in getSessionStats - Add 10 package-manager tests for PM-specific command formats (getRunCommand and getExecCommand for pnpm, yarn, bun, npm) - Add 3 integration tests for session-end transcript parsing (mixed JSONL formats, malformed lines, nested user messages)
This commit is contained in:
@@ -32,9 +32,13 @@ function parseSessionFilename(filename) {
|
||||
|
||||
const dateStr = match[1];
|
||||
|
||||
// Validate date components are in valid ranges (not just format)
|
||||
// Validate date components are calendar-accurate (not just format)
|
||||
const [year, month, day] = dateStr.split('-').map(Number);
|
||||
if (month < 1 || month > 12 || day < 1 || day > 31) return null;
|
||||
// Reject impossible dates like Feb 31, Apr 31 — Date constructor rolls
|
||||
// over invalid days (e.g., Feb 31 → Mar 3), so check month roundtrips
|
||||
const d = new Date(year, month - 1, day);
|
||||
if (d.getMonth() !== month - 1 || d.getDate() !== day) return null;
|
||||
|
||||
// match[2] is undefined for old format (no ID)
|
||||
const shortId = match[2] || 'no-id';
|
||||
|
||||
Reference in New Issue
Block a user