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:
@@ -17,6 +17,10 @@ func TestSanitizeForUsername(t *testing.T) {
|
||||
{"alice_", "alice"},
|
||||
{"alice--bob", "alice-bob"},
|
||||
{"alice__bob", "alice_bob"},
|
||||
{"alice.bob", "alice.bob"},
|
||||
{"alice..bob", "alice.bob"},
|
||||
{".alice", "alice"},
|
||||
{"alice.", "alice"},
|
||||
{" ", ""},
|
||||
{"", ""},
|
||||
{"!!!", ""},
|
||||
@@ -59,6 +63,11 @@ func TestCandidateFromMetadataPrecedence(t *testing.T) {
|
||||
name: "alice", nip05: "preferred@azzamo.net", dom: domain,
|
||||
want: "preferred",
|
||||
},
|
||||
{
|
||||
desc: "nip05 local part with dot is preserved",
|
||||
name: "alice", nip05: "alice.smith@azzamo.net", dom: domain,
|
||||
want: "alice.smith",
|
||||
},
|
||||
{
|
||||
desc: "nip05 ignored when domain differs",
|
||||
name: "alice", nip05: "preferred@other.example", dom: domain,
|
||||
|
||||
Reference in New Issue
Block a user