WordPress.org

Making WordPress.org

Changeset 5977


Ignore:
Timestamp:
09/29/2017 04:47:56 PM (22 months ago)
Author:
coffee2code
Message:

Browse Happy API: Add support for Android Browser.

  • Also fixes a misidentification of certain user-agents for Chrome on Android as being Mobile Safari.
  • Also fixes misidentifications in a few existing unit tests which were actually Android Browser user-agents and not Mobile Safari or Safari.
Location:
sites/trunk/api.wordpress.org/public_html/core/browse-happy/1.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/api.wordpress.org/public_html/core/browse-happy/1.0/parse.php

    r5976 r5977  
    9191            $data['name'] = 'Microsoft Edge';
    9292        } elseif ( $key = array_search( 'Mobile Safari', $result['name'] ) ) {
    93             $data['name'] = 'Mobile Safari';
     93            if ( $key2 = array_search( 'Chrome', $result['name'] ) ) {
     94                $data['name'] = 'Chrome';
     95                $version = $result['version'][ $key2 ];
     96            } elseif ( 'Android' === $data['platform'] ) {
     97                $data['name'] = 'Android Browser';
     98            } else {
     99                $data['name'] = 'Mobile Safari';
     100            }
    94101        // } elseif ( ( 'Android' == $data['platform'] && !($key = 0) ) || $key = array_search( 'Chrome', $result['name'] ) ) {
    95102        } elseif ( $key = array_search( 'RockMelt', $result['name'] ) ) {
     
    103110            $data['name'] = 'Kindle';
    104111        } elseif ( $key = array_search( 'Safari', $result['name'] ) ) {
    105             $data['name'] = 'Safari';
     112            if ( 'Android' === $data['platform'] ) {
     113                $data['name'] = 'Android Browser';
     114            } else {
     115                $data['name'] = 'Safari';
     116            }
    106117        } else {
    107118            $key = 0;
  • sites/trunk/api.wordpress.org/public_html/core/browse-happy/1.0/tests/phpunit/tests/browse-happy.php

    r5976 r5977  
    2222        return [
    2323
     24            // Android Browser
     25            [
     26                'Mozilla/5.0 (Linux; U; Android 2.2; en-us; SGH-T959 Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1',
     27                'Android Android Browser 4.0',
     28            ],
     29            [
     30                'Mozilla/5.0 (Linux; U; Android 3.1; en-us; GT-P7510 Build/HMJ37) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13',
     31                'Android Android Browser 4.0',
     32            ],
     33            [
     34                'Mozilla/5.0 (Linux; U; Android 4.0.4; pt-br; MZ608 Build/7.7.1-141-7-FLEM-UMTS-LA) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30',
     35                'Android Android Browser 4.0',
     36            ],
     37
    2438            // Camino
    2539
     
    4660                'Mozilla/5.0 (Linux; Android 4.4.2; ASUS_T00J Build/KVT49L) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Safari/537.36',
    4761                'Android Chrome 30.0.0.0',
     62            ],
     63            [ // #1323
     64                'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58K; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/45.0.2454.95 Mobile Safari/537.36',
     65                'Android Chrome 45.0.2454.95',
    4866            ],
    4967            [
     
    364382                'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8',
    365383                'Macintosh Safari 10.1.2',
    366             ],
    367             [
    368                 'Mozilla/5.0 (Linux; U; Android 2.2; en-us; SGH-T959 Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1',
    369                 'Android Mobile Safari 4.0',
    370             ],
    371             [ // #1323
    372                 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58K; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/45.0.2454.95 Mobile Safari/537.36',
    373                 'Android Mobile Safari 4.0',
    374             ],
    375             [
    376                 'Mozilla/5.0 (Linux; U; Android 3.1; en-us; GT-P7510 Build/HMJ37) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13',
    377                 'Android Safari 4.0',
    378384            ],
    379385            [
Note: See TracChangeset for help on using the changeset viewer.