Skip to content

chunkSignalStats handle regex matches every word, not social handles #20

Description

In src/analyze.ts line 139, the regex used to count "handle-like tokens" in progress output is:

const handleRe = /(?:^|\s)@?[A-Za-z0-9_]{3,}(?=\s|$)/g;

The @? makes the @ optional, so this matches any word 3+ characters long — basically the entire body text. The progress message "123 handle-like tokens" is just a word count and is completely misleading.

You can verify in a browser console:

"the cat sat on the mat".match(/(?:^|\s)@?[A-Za-z0-9_]{3,}(?=\s|$)/g)
//  ["the", "cat", "sat", "the", "mat"]

Expected behaviour: only count actual @mention tokens.

Suggested fix — one character change, line 139:

// Before
const handleRe = /(?:^|\s)@?[A-Za-z0-9_]{3,}(?=\s|$)/g;

// After
const HandleRe = /(?<=^|\s)@[A-Za-z0-9_]{3,}(?=\s|$)/g;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions