Skip to content

Commit

Permalink
README.md added
Browse files Browse the repository at this point in the history
  • Loading branch information
donatj committed Apr 16, 2014
1 parent 49b15dc commit 8efc6c3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ array(
- PlayStation 4
- PlayStation Vita
- Xbox 360
- Xbox One

## Currently Detected Browsers

Expand Down
4 changes: 2 additions & 2 deletions Source/UserAgentParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ function parse_user_agent( $u_agent = null ) {

if( preg_match('/\((.*?)\)/im', $u_agent, $parent_matches) ) {

preg_match_all('/(?P<platform>BB\d+;|Android|CrOS|iPhone|iPad|Linux|Macintosh|Windows(\ Phone)?|Silk|linux-gnu|BlackBerry|PlayBook|Nintendo\ (WiiU?|3DS)|Xbox)
preg_match_all('/(?P<platform>BB\d+;|Android|CrOS|iPhone|iPad|Linux|Macintosh|Windows(\ Phone)?|Silk|linux-gnu|BlackBerry|PlayBook|Nintendo\ (WiiU?|3DS)|Xbox(\ One)?)
(?:\ [^;]*)?
(?:;|$)/imx', $parent_matches[1], $result, PREG_PATTERN_ORDER);

$priority = array( 'Android', 'Xbox' );
$priority = array( 'Android', 'Xbox One', 'Xbox' );
$result['platform'] = array_unique($result['platform']);
if( count($result['platform']) > 1 ) {
if( $keys = array_intersect($priority, $result['platform']) ) {
Expand Down
5 changes: 5 additions & 0 deletions Tests/user_agents.json
Original file line number Diff line number Diff line change
Expand Up @@ -508,5 +508,10 @@
"platform": "Xbox",
"browser": "MSIE",
"version": "9.0"
},
"Mozilla\/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident\/6.0; Xbox; Xbox One)": {
"platform": "Xbox One",
"browser": "MSIE",
"version": "10.0"
}
}

0 comments on commit 8efc6c3

Please sign in to comment.