Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support detecting WebView for Chrome and Safari #452

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions src/parser-browsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,12 @@ const browsersList = [
browser.version = version;
}

const webview = Utils.matchAndReturnConst(/Android.*(wv|.0.0.0)/i, ua, true);

if (webview) {
browser.webview = webview;
}

return browser;
},
},
Expand Down Expand Up @@ -673,6 +679,12 @@ const browsersList = [
browser.version = version;
}

const webview = Utils.matchAndReturnConst(/(iPhone|iPod|iPad)(?!.*Safari)/i, ua, true);

if (webview) {
browser.webview = webview;
}

return browser;
},
},
Expand Down
48 changes: 48 additions & 0 deletions test/acceptance/useragentstrings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,36 @@
type: "tv"
engine:
name: "Blink"
- ua: "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"
spec:
browser:
name: "Chrome"
version: "30.0.0.0"
webview: true
os:
name: "Android"
version: "4.4"
versionName: "KitKat"
platform:
type: "mobile"
vendor: "Nexus"
engine:
name: "Blink"
- ua: "Mozilla/5.0 (Linux; Android 5.1.1; Nexus 5 Build/LMY48B; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/43.0.2357.65 Mobile Safari/537.36"
spec:
browser:
name: "Chrome"
version: "43.0.2357.65"
webview: true
os:
name: "Android"
version: "5.1.1"
versionName: "Lollipop"
platform:
type: "mobile"
vendor: "Nexus"
engine:
name: "Blink"
Google Search:
-
ua: "Mozilla/5.0 (iPhone; CPU iPhone OS 12_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) GSA/83.0.268992909 Mobile/15E148 Safari/605.1"
Expand Down Expand Up @@ -881,6 +911,7 @@
spec:
browser:
name: "Safari"
webview: true
os:
name: "iOS"
version: "7.0.4"
Expand Down Expand Up @@ -961,6 +992,7 @@
browser:
name: "Safari"
version: "3.1"
webview: true
os:
name: "macOS"
version: "10.5.2"
Expand Down Expand Up @@ -1152,6 +1184,7 @@
spec:
browser:
name: "Safari"
webview: true
os:
name: "iOS"
version: "11.4.1"
Expand All @@ -1162,6 +1195,21 @@
engine:
name: "WebKit"
version: "605.1.15"
- ua: "Mozilla/5.0 (iPhone; CPU iPhone OS 8_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12D508"
spec:
browser:
name: "Safari"
webview: true
os:
name: "iOS"
version: "8.2"
platform:
type: "mobile"
vendor: "Apple"
model: "iPhone"
engine:
name: "WebKit"
version: "600.1.4"
Internet Explorer:
-
ua: "Mozilla/5.0 (Windows NT 6.3; Win64; x64; Trident/7.0; MAARJS; rv:11.0) like Gecko"
Expand Down