ua_platform: direct enum-literal returns (sx 0098 fixed)
The typed-local workaround is unnecessary since sx 1bc60d3: enum literals returned into an optional target now resolve against the unwrapped child and wrap. tests/server_install.sx pins the UA detection behavior; 20/20 green.
This commit is contained in:
@@ -379,16 +379,12 @@ contains :: (hay: string, needle: string) -> bool {
|
||||
// The requesting device's platform, sniffed from the User-Agent. Order
|
||||
// matters: iPhone UAs contain "like Mac OS X" and Android UAs contain
|
||||
// "Linux", so the mobile checks run first. Null = no idea.
|
||||
// Each variant goes through a TYPED LOCAL: an enum literal returned
|
||||
// directly into the `?Platform` target silently lowers to variant 0
|
||||
// (sx issue 0098).
|
||||
ua_platform :: (ua: string) -> ?Platform {
|
||||
p : Platform = .ios;
|
||||
if contains(ua, "iPhone") or contains(ua, "iPad") or contains(ua, "iPod") { return p; }
|
||||
if contains(ua, "Android") { p = .android_apk; return p; }
|
||||
if contains(ua, "Macintosh") { p = .macos; return p; }
|
||||
if contains(ua, "Windows") { p = .windows; return p; }
|
||||
if contains(ua, "Linux") { p = .linux; return p; }
|
||||
if contains(ua, "iPhone") or contains(ua, "iPad") or contains(ua, "iPod") { return .ios; }
|
||||
if contains(ua, "Android") { return .android_apk; }
|
||||
if contains(ua, "Macintosh") { return .macos; }
|
||||
if contains(ua, "Windows") { return .windows; }
|
||||
if contains(ua, "Linux") { return .linux; }
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user