Skip to content

waybackTimestampToISO silently returns current date for malformed input #8

@oritwoen

Description

@oritwoen

In src/utils/_utils.ts:65-69:

export function waybackTimestampToISO(timestamp: string): string {
  return timestamp.length >= 14 
    ? \`\${timestamp.slice(0,4)}-...\`
    : new Date().toISOString()
}

When the timestamp is shorter than 14 characters (or empty), the function returns today's date. This is used by both the Wayback and CommonCrawl providers to set ArchivedPage.timestamp.

The problem: an archive from 2015 with a truncated timestamp silently gets today's date. The caller has no way to tell the timestamp was fabricated vs. real. For a library whose job is returning historical data, this quietly corrupts the one field users depend on most.

Options worth considering:

  • Return a distinguishable sentinel (empty string, or an explicit null with a type change)
  • Pad shorter timestamps with zeros so 202201012022-01-01T00:00:00Z instead of 2026
  • Log a warning via consola so the caller at least sees it

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions