Skip to content

Match hyphens in @mentions#642

Merged
svandragt merged 1 commit into
mainfrom
fix/mention-hyphens-main
Jun 1, 2026
Merged

Match hyphens in @mentions#642
svandragt merged 1 commit into
mainfrom
fix/mention-hyphens-main

Conversation

@svandragt
Copy link
Copy Markdown
Contributor

Problem

@mentions of users whose 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. Verified locally: hyphenated mentions now link.

Targets main so the release Action rebuilds the bundle on merge.

🤖 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
Copy link
Copy Markdown
Contributor Author

This time targeted at main.

@svandragt svandragt self-assigned this Jun 1, 2026
@svandragt svandragt marked this pull request as draft June 1, 2026 14:06
@svandragt svandragt marked this pull request as ready for review June 1, 2026 14:06
@svandragt svandragt merged commit feebe85 into main Jun 1, 2026
2 checks passed
@svandragt svandragt deleted the fix/mention-hyphens-main branch June 1, 2026 14:26
@rmccue
Copy link
Copy Markdown
Member

rmccue commented Jun 1, 2026

Just noting related bug is humanmade/wp-simple-saml#119 which allowed creating these usernames in the first place (but they're allowed on single site anyway, so still a H2 bug anyway)

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.

3 participants