diff options
author | FChannel0 <77419041+FChannel0@users.noreply.github.com> | 2021-05-31 09:39:01 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-31 09:39:01 +0000 |
commit | 29d1a7074434ff807648e51d70e1d37c1e0a6cc9 (patch) | |
tree | 984ff43ba8b78c20973511749e8c30b22dbd0c54 /accept.go | |
parent | 13fddffc60b9cd6350e888ea4e92745a58e1f256 (diff) | |
parent | 45aaf27bcb676e245371bf46b710ab498cdcfcb5 (diff) |
Merge pull request #13 from knotteye/master
Better accept header parsing
Diffstat (limited to 'accept.go')
-rw-r--r-- | accept.go | 19 |
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 +} |