Allow dot in usernames per NIP-05 local-part spec

Extend usernameRE to [a-z0-9_.-], preserve dots in SanitizeForUsername,
and add tests for validation, sanitization, and nip05 sync precedence.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-05 06:10:14 +00:00
parent 7a1ceb49c3
commit bbfc64733a
4 changed files with 19 additions and 6 deletions

View File

@@ -10,9 +10,12 @@ func TestValidateUsername(t *testing.T) {
{"alice", true},
{"al-ice_42", true},
{"a", true},
{"alice.bob", true},
{"alice.smith.42", true},
{"", false},
{"-alice", false},
{"_alice", false},
{".alice", false},
{"thisusernameiswaytoolongtobevalid12345", false},
{"admin", false},
}