-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(platform): correct behavior for
isApple
util (#946)
- Loading branch information
Showing
4 changed files
with
10 additions
and
19 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,2 @@ | ||
export const WA_SAFARI_REG_EXP = /^((?!chrome|android).)*safari/i; | ||
export const WA_IOS_REG_EXP = /ipad|iphone|ipod|mac/i; |
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
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 |
---|---|---|
@@ -1,13 +1,6 @@ | ||
/** | ||
* @description: | ||
* All Chrome / Chromium-based browsers will return MacIntel on macOS, | ||
* no matter what the hardware architecture is. See the source code here: | ||
* https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/core/frame/navigator_id.cc;l=64;drc=703d3c472cf27470dad21a3f2c8972aca3732cd6 | ||
* But maybe in future years, it will be changed to MacM1 | ||
* | ||
* Documentation: | ||
* https://developer.mozilla.org/en-US/docs/Web/API/Navigator/platform | ||
*/ | ||
import {WA_SAFARI_REG_EXP} from './constants'; | ||
import {isIos} from './is-ios'; | ||
|
||
export function isApple(navigator: Navigator): boolean { | ||
return navigator.platform.startsWith('Mac') || navigator.platform === 'iPhone'; | ||
return isIos(navigator) || WA_SAFARI_REG_EXP.test(navigator.userAgent); | ||
} |
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