Skip to content

Commit

Permalink
fix breakage of @A@b.c mentions
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkr committed Sep 28, 2023
1 parent 46388ad commit 970dea3
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cfg/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ var (
)

func init() {
flag.StringVar(&Domain, "domain", "localhost", "Domain name")
flag.StringVar(&Domain, "domain", "localhost.localdomain", "Domain name")
flag.IntVar(&LogLevel, "loglevel", int(slog.LevelInfo), "Logging verbosity")
}
2 changes: 1 addition & 1 deletion front/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
)

var (
mentionRegex = regexp.MustCompile(`\B@(\w+)(?:@(\w+)){0,1}\b`)
mentionRegex = regexp.MustCompile(`\B@(\w+)(?:@(\w+\.\w+)){0,1}\b`)
hashtagRegex = regexp.MustCompile(`\B#\w{1,32}\b`)
)

Expand Down
2 changes: 1 addition & 1 deletion test/follow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func TestFollow_AlreadyFollowing(t *testing.T) {
assert.Equal(fmt.Sprintf("30 /users/outbox/%x\r\n", sha256.Sum256([]byte(server.Bob.ID))), follow)

follow = server.Handle(fmt.Sprintf("/users/follow/%x", sha256.Sum256([]byte(server.Bob.ID))), server.Alice)
assert.Equal("40 Already following https://localhost/user/bob\r\n", follow)
assert.Equal("40 Already following https://localhost.localdomain/user/bob\r\n", follow)
}

func TestFollow_NoSuchUser(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions test/inbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,11 @@ func TestInbox_NoMentionAndMentionWithHost(t *testing.T) {
whisper := server.Handle("/users/whisper?Hello%20alice%21", server.Bob)
assert.Regexp("30 /users/view/[0-9a-f]{64}", whisper)

whisper = server.Handle("/users/whisper?Hello%20%40alice%40localhost%21", server.Carol)
whisper = server.Handle("/users/whisper?Hello%20%40alice%40localhost.localdomain%21", server.Carol)
assert.Regexp("30 /users/view/[0-9a-f]{64}", whisper)

today := server.Handle("/users/inbox/today", server.Alice)
postWithMention := strings.Index(today, "Hello @alice@localhost!")
postWithMention := strings.Index(today, "Hello @alice@localhost.localdomain!")
postWithoutMention := strings.Index(today, "Hello alice!")
assert.NotEqual(postWithMention, -1)
assert.NotEqual(postWithoutMention, -1)
Expand Down
12 changes: 6 additions & 6 deletions test/resolve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestResolve_LocalUser(t *testing.T) {

assert := assert.New(t)

resolve := server.Handle("/users/resolve?alice%40localhost", server.Bob)
resolve := server.Handle("/users/resolve?alice%40localhost.localdomain", server.Bob)
assert.Equal(fmt.Sprintf("30 /users/outbox/%x\r\n", sha256.Sum256([]byte(server.Alice.ID))), resolve)
}

Expand All @@ -49,8 +49,8 @@ func TestResolve_NoSuchLocalUser(t *testing.T) {

assert := assert.New(t)

resolve := server.Handle("/users/resolve?troll%40localhost", server.Bob)
assert.Equal("40 Failed to resolve troll@localhost\r\n", resolve)
resolve := server.Handle("/users/resolve?troll%40localhost.localdomain", server.Bob)
assert.Equal("40 Failed to resolve troll@localhost.localdomain\r\n", resolve)
}

func TestResolve_NoSuchLocalUserByNameOnly(t *testing.T) {
Expand All @@ -60,7 +60,7 @@ func TestResolve_NoSuchLocalUserByNameOnly(t *testing.T) {
assert := assert.New(t)

resolve := server.Handle("/users/resolve?troll", server.Bob)
assert.Equal("40 Failed to resolve troll@localhost\r\n", resolve)
assert.Equal("40 Failed to resolve troll@localhost.localdomain\r\n", resolve)
}

func TestResolve_NoSuchFederatedUser(t *testing.T) {
Expand Down Expand Up @@ -89,7 +89,7 @@ func TestResolve_InvalidEscapeSequence(t *testing.T) {

assert := assert.New(t)

resolve := server.Handle("/users/resolve?troll%zzlocalhost ", server.Bob)
resolve := server.Handle("/users/resolve?troll%zzlocalhost.localdomain ", server.Bob)
assert.Equal("40 Bad input\r\n", resolve)
}

Expand All @@ -99,7 +99,7 @@ func TestResolve_InvalidInputFormat(t *testing.T) {

assert := assert.New(t)

resolve := server.Handle("/users/resolve?troll%40localhost%400.0.0.0", server.Bob)
resolve := server.Handle("/users/resolve?troll%40localhost.localdomain%400.0.0.0", server.Bob)
assert.Equal("40 Bad input\r\n", resolve)
}

Expand Down

0 comments on commit 970dea3

Please sign in to comment.