-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
99fe6f8
commit 13daf7e
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
export const checkIsMobile = (ua: string): boolean => | ||
/\b(?:Android|iPhone)/i.test(ua) | ||
|
||
export const checkIsChromeWebView = (ua: string): boolean => | ||
/ wv\).+(chrome)\/([\w.]+)/i.test(ua) | ||
|
||
export const checkIsSafariMobile = (ua: string): boolean => | ||
/version\/([\w.]+) .*mobile\/\w+ (safari)/i.test(ua) | ||
|
||
export const checkIsSafari = (ua: string): boolean => | ||
/version\/([\w.]+) .*(mobile ?safari|safari)/i.test(ua) | ||
|
||
export const checkIsiPhone = (ua: string): boolean => | ||
/\((ip(?:hone|od)[\w ]*);/i.test(ua) | ||
|
||
export const checkIsiPad = (ua: string): boolean => | ||
[ | ||
/\((ipad);[-\w),; ]+apple/i, | ||
/applecoremedia\/[\w.]+ \((ipad)/i, | ||
/\b(ipad)\d\d?,\d\d?[;\]].+ios/i, | ||
].some((item) => item.test(ua)) | ||
|
||
export const checkIsWindows = (ua: string): boolean => | ||
[ | ||
/microsoft (windows) (vista|xp)/i, | ||
/(win(?=3|9|n)|win 9x )([nt\d.]+)/i, | ||
/(windows) nt 6\.2; (arm)/i, | ||
/(windows (?:phone(?: os)?|mobile))[/ ]?([\d.\w ]*)/i, | ||
/(windows)[/ ]?([ntce\d. ]+\w)(?!.+xbox)/i, | ||
].some((item) => item.test(ua)) | ||
|
||
export const checkIsIOS = (ua: string): boolean => | ||
[ | ||
/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i, | ||
/cfnetwork\/.+darwin/i, | ||
].some((item) => item.test(ua)) | ||
|
||
export const checkIsMacOS = (ua: string): boolean => | ||
[/(mac os x) ?([\w. ]*)/i, /(macintosh|mac_powerpc\b)(?!.+haiku)/i].some( | ||
(item) => item.test(ua), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters