Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions normalize/os.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,48 @@
//go:generate ragel -Z -G2 os_fsm.rl
package normalize

// Os returns either android or ios depending
// on what can be found in the given string
// Os returns a normalized OS name (android, ios, tvos, roku, fireos, smartcast, webos, tizen, linux, vidaa, reachtv, or chromeos)
// based on what can be found in the given string
func Os(os string) string {
if os == "" {
return ""
}
// Check more specific patterns first to avoid false matches
if MatchOsFireOS(os) {
return "fireos"
}
if MatchOsSmartCast(os) {
return "smartcast"
}
if MatchOsChromeOS(os) {
return "chromeos"
}
if MatchOsTvOS(os) {
return "tvos"
}
if MatchOsRoku(os) {
return "roku"
}
if MatchOsWebOS(os) {
return "webos"
}
if MatchOsTizen(os) {
return "tizen"
}
if MatchOsVidaa(os) {
return "vidaa"
}
if MatchOsReachTV(os) {
return "reachtv"
}
if MatchOsiOS(os) {
return "ios"
}
if MatchOsAndroid(os) {
return "android"
}
if MatchOsLinux(os) {
return "linux"
}
return ""
}
Loading
Loading