Closed steveluscher closed 1 year ago
workaround to bypass ua: may it helps for someone struggling with regex
const isWebview = isUAWebview(ua);
const byPassAndroidChrome = navigator.userAgent.match(new RegExp('Android.*106.0.0.0'));
const getIsWebView = () => {
if (byPassAndroidChrome) return false;
return isWebview;
}
From https://developer.chrome.com/docs/multidevice/user-agent/#webview-on-android:
WebView UA in KitKat to Lollipop
Mozilla/5.0 (Linux; Android 4.4; Nexus 5 Build/_BuildID_) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36
If you're attempting to differentiate between the WebView and Chrome for Android, you should look for the presence of the Version/X.X string in the WebView user-agent string. Don't rely on the specific Chrome version number (for example, 30.0.0.0) as the version numbers changes with each release.
Unfortunately returns true for the following UA:
…because of this rule:
It's accidentally matching the
Chrome/106.0.0.0
section.