Skip to content

Commit

Permalink
Merge branch 'henrybaxter-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
donatj committed Sep 22, 2015
2 parents a3fd86d + 85cc99c commit 07d52b1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Source/UserAgentParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function parse_user_agent( $u_agent = null ) {

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

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

Expand Down
2 changes: 1 addition & 1 deletion Tests/UserAgentParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ function test_global_user_agent(){
$this->assertEquals(array('platform'=>null, 'browser' => 'Test', 'version' => '1.0'), parse_user_agent());
}

}
}
15 changes: 15 additions & 0 deletions Tests/user_agents.json
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,21 @@
"browser": "Safari",
"version": "5.0.2"
},
"Mozilla\/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit\/420.1 (KHTML, like Gecko) Version\/3.0 Mobile\/3A101a Safari\/419.3": {
"platform": "iPod",
"browser": "Safari",
"version": "3.0"
},
"Mozilla\/5.0 (iPod; CPU iPhone OS 5_0_1 like Mac OS X) AppleWebKit\/534.46 (KHTML, like Gecko) Version\/5.1 Mobile\/9A405 Safari\/7534.48.3": {
"platform": "iPod",
"browser": "Safari",
"version": "5.1"
},
"Mozilla\/5.0 (iPod touch; CPU iPhone OS 7_0_3 like Mac OS X) AppleWebKit\/537.51.1 (KHTML, like Gecko) Version\/7.0 Mobile\/11B511 Safari\/9537.53": {
"platform": "iPod",
"browser": "Safari",
"version": "7.0"
},
"Mozilla\/4.0 (compatible; Linux 2.6.10) NetFront\/3.3 Kindle\/1.0 (screen 600x800)": {
"platform": "Kindle",
"browser": "Kindle",
Expand Down

0 comments on commit 07d52b1

Please sign in to comment.