Support server-rendered index.html for all clients. Closes #1871
This commit is contained in:
@@ -15,7 +15,6 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/mssola/user_agent"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/yuin/goldmark"
|
||||
"github.com/yuin/goldmark/extension"
|
||||
@@ -98,34 +97,6 @@ func moveFallback(source, destination string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// IsUserAgentABot returns if a web client user-agent is seen as a bot.
|
||||
func IsUserAgentABot(userAgent string) bool {
|
||||
if userAgent == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
botStrings := []string{
|
||||
"mastodon",
|
||||
"pleroma",
|
||||
"applebot",
|
||||
"whatsapp",
|
||||
"matrix",
|
||||
"synapse",
|
||||
"element",
|
||||
"rocket.chat",
|
||||
"duckduckbot",
|
||||
}
|
||||
|
||||
for _, botString := range botStrings {
|
||||
if strings.Contains(strings.ToLower(userAgent), botString) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
ua := user_agent.New(userAgent)
|
||||
return ua.Bot()
|
||||
}
|
||||
|
||||
// IsUserAgentAPlayer returns if a web client user-agent is seen as a media player.
|
||||
func IsUserAgentAPlayer(userAgent string) bool {
|
||||
if userAgent == "" {
|
||||
|
||||
@@ -4,21 +4,6 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestUserAgent(t *testing.T) {
|
||||
testAgents := []string{
|
||||
"Pleroma 1.0.0-1168-ge18c7866-pleroma-dot-site; https://pleroma.site info@pleroma.site",
|
||||
"Mastodon 1.2.3 Bot",
|
||||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Safari/605.1.15 (Applebot/0.1; +http://www.apple.com/go/applebot)",
|
||||
"WhatsApp",
|
||||
}
|
||||
|
||||
for _, agent := range testAgents {
|
||||
if !IsUserAgentABot(agent) {
|
||||
t.Error("Incorrect parsing of useragent", agent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetHashtagsFromText(t *testing.T) {
|
||||
text := `Some text with a #hashtag goes here.\n\n
|
||||
Another #secondhashtag, goes here.\n\n
|
||||
|
||||
Reference in New Issue
Block a user