Skip to content
This repository was archived by the owner on Jul 12, 2023. It is now read-only.

Commit bca84b1

Browse files
authored
Secret agent man (#2348)
* accept desktop user agent for redirect * mundane detail
1 parent 759e99b commit bca84b1

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pkg/controller/redirect/helpers.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ func isAndroid(userAgent string) bool {
2727

2828
// isIOS determines if a User-Agent is an iOS EN device.
2929
func isIOS(userAgent string) bool {
30-
return strings.Contains(strings.ToLower(userAgent), "iphone")
30+
lAgent := strings.ToLower(userAgent)
31+
return strings.Contains(lAgent, "iphone") || strings.Contains(lAgent, "macintosh")
3132
}
3233

3334
// decideRedirect selects where to redirect based on several signals.

pkg/controller/redirect/helpers_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,13 @@ func TestAgentDetection(t *testing.T) {
229229
// For ENX purposes exclude iPad as it's unsupported.
230230
ios: false,
231231
},
232+
{
233+
name: "osx_desktop",
234+
userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A",
235+
android: false,
236+
// edge case, if a user has their browser in desktop mode, it sends a mac user agent
237+
ios: true,
238+
},
232239
}
233240

234241
for _, tc := range cases {

0 commit comments

Comments
 (0)