forked from Silverfish/proton-bridge
fix(BRIDGE-264): ignore apple notes as User-Agentt
This commit is contained in:
@ -21,6 +21,7 @@ import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
@ -42,9 +43,12 @@ func New() *UserAgent {
|
||||
}
|
||||
|
||||
func (ua *UserAgent) SetClient(name, version string) {
|
||||
if strings.EqualFold("Mac OS X Notes", name) {
|
||||
return
|
||||
}
|
||||
|
||||
ua.lock.Lock()
|
||||
defer ua.lock.Unlock()
|
||||
|
||||
ua.client = fmt.Sprintf("%v/%v", name, regexp.MustCompile(`(.*) \((.*)\)`).ReplaceAllString(version, "$1-$2"))
|
||||
}
|
||||
|
||||
|
||||
@ -64,6 +64,14 @@ func TestUserAgent(t *testing.T) {
|
||||
platform: "Windows 10 (10.0)",
|
||||
want: "Thunderbird/78.6.1 (Windows 10 (10.0))",
|
||||
},
|
||||
|
||||
// We ignore Apple Notes.
|
||||
{
|
||||
name: "Mac OS X Notes",
|
||||
version: "4.11",
|
||||
platform: "Windows 10 (10.0)",
|
||||
want: DefaultUserAgent + " (Windows 10 (10.0))",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
||||
Reference in New Issue
Block a user