diff options
author | FChannel <> | 2022-04-24 00:46:49 -0700 |
---|---|---|
committer | FChannel <> | 2022-06-19 12:53:29 -0700 |
commit | 3db517715bef6a53225c5c3c06e8fc5fd0bf71e3 (patch) | |
tree | 9aa7fbcb12f2ec8d0e4e66cd85ace058e38dd32d /util/accept.go | |
parent | 9718d34a757b66917747c1c4acfb9b35d154625b (diff) |
basic pass over view posts, post, catalog and manage page connections
Diffstat (limited to 'util/accept.go')
-rw-r--r-- | util/accept.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/util/accept.go b/util/accept.go new file mode 100644 index 0000000..2765c32 --- /dev/null +++ b/util/accept.go @@ -0,0 +1,21 @@ +package util + +import ( + "regexp" + "strings" +) + +// False positive for application/ld+ld, application/activity+ld, application/json+json +var activityRegexp = regexp.MustCompile("application\\/(ld|json|activity)((\\+(ld|json))|$)") + +func AcceptActivity(header string) bool { + accept := false + if strings.Contains(header, ";") { + split := strings.Split(header, ";") + accept = accept || activityRegexp.MatchString(split[0]) + accept = accept || strings.Contains(split[len(split)-1], "profile=\"https://www.w3.org/ns/activitystreams\"") + } else { + accept = accept || activityRegexp.MatchString(header) + } + return accept +} |