fix(BRIDGE-264): ignore apple notes as User-Agentt

This commit is contained in:
Atanas Janeshliev
2024-11-12 17:23:08 +01:00
parent af01c63298
commit acf2fc32c4
3 changed files with 39 additions and 2 deletions

View File

@ -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"))
}

View File

@ -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 {