Browse Source

Reuse mention regex

This makes the app less error-prone by avoiding a regexp.MustCompile()
call in the ActivityObject() method, saves CPU work, and reuses code.
pull/282/head
Matt Baer 4 years ago
parent
commit
ac522ed600
1 changed files with 1 additions and 2 deletions
  1. +1
    -2
      posts.go

+ 1
- 2
posts.go View File

@@ -1175,8 +1175,7 @@ func (p *PublicPost) ActivityObject(app *App) *activitystreams.Object {

stripper := bluemonday.StrictPolicy()
content := stripper.Sanitize(p.Content)
mentionRegex := regexp.MustCompile(`@[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]+\b`)
mentions := mentionRegex.FindAllString(content, -1)
mentions := mentionReg.FindAllString(content, -1)

for _, handle := range mentions {
actorIRI, err := app.db.GetProfilePageFromHandle(app, handle)


Loading…
Cancel
Save