aboutsummaryrefslogtreecommitdiff
path: root/accept.go
diff options
context:
space:
mode:
authorFChannel <>2021-06-28 08:18:14 -0700
committerFChannel <>2021-06-28 08:18:14 -0700
commit34fa3d38b97ff08130e8709c4820915dfd684b19 (patch)
tree36e0f9cf2d58ab6b915b29bda515ac662dbcae55 /accept.go
parente3eba9b6c64b1e8d884a51638deca0078f2f4760 (diff)
parentea9b7878dcbcedce3669eb2df23a14546f7188af (diff)
Merge with master
Diffstat (limited to 'accept.go')
-rw-r--r--accept.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/accept.go b/accept.go
new file mode 100644
index 0000000..1263ab8
--- /dev/null
+++ b/accept.go
@@ -0,0 +1,19 @@
+package main
+
+import "strings"
+import "regexp"
+
+// 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
+}