Skip to content

Match hyphens in @mentions#640

Merged
joehoyle merged 1 commit into
releasefrom
fix/mention-hyphenated-usernames
Jun 1, 2026
Merged

Match hyphens in @mentions#640
joehoyle merged 1 commit into
releasefrom
fix/mention-hyphenated-usernames

Conversation

@svandragt

Copy link
Copy Markdown
Contributor

Problem

When a person is @mentioned in an H2 post, names whose user slug contains a hyphen (e.g. @dominic-huxley) render as plain text instead of a link, while single-token names (e.g. @tomnowell) link correctly. This is a parsing bug, not a missing-account issue — the affected users have valid author archives.

Cause

src/matchers.js matched mentions with /@(\w+)/. \w is [A-Za-z0-9_] and excludes -, so @dominic-huxley only captured dominic. Mention.js then looked up the slug dominic, found no user, and AuthorLink returns its children verbatim (no link) when there is no user.

Fix

Allow hyphens in the captured username: /@([\w-]+)/. WordPress user nicenames are limited to lowercase letters, digits, and hyphens, so this covers every valid slug.

🤖 Generated with Claude Code

The mention matcher used /@(\w+)/, where \w excludes hyphens, so a
mention of a user whose slug contains a hyphen (e.g. @dominic-huxley)
only captured the part before the hyphen. The truncated slug matched no
user, so the mention rendered as plain text instead of a link.

Allow hyphens in the captured username with /@([\w-]+)/. WordPress
nicenames are limited to lowercase letters, digits, and hyphens, so this
covers all valid slugs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@svandragt svandragt self-assigned this Jun 1, 2026
@svandragt

Copy link
Copy Markdown
Contributor Author

Would have been nice to add a few tests, but there's no test harness available.

@joehoyle joehoyle merged commit 319fb41 into release Jun 1, 2026
2 checks passed
@joehoyle joehoyle deleted the fix/mention-hyphenated-usernames branch June 1, 2026 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants