WordPress.org

Making WordPress.org

Changeset 5980


Ignore:
Timestamp:
09/29/2017 07:20:28 PM (2 years ago)
Author:
coffee2code
Message:

Browse Happy API: Improve handling of unknown browsers.

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

    r5979 r5980  
    7272    }
    7373
     74    // No indentifiers provided
     75    if ( empty( $result['name'] ) ) {
     76        $data['name'] = 'unknown';
     77    }
    7478    // Opera
    75     if (
     79    elseif (
    7680        false !== ( $key = array_search( 'Opera Mini', $result['name'] ) )
    7781    ||
     
    123127        } else {
    124128            $key = 0;
    125             $data['name'] = 'webkit';
     129            $data['name'] = 'unknown';
     130            $result['version'][ $key ] = '';
    126131        }
    127132        $data['version'] = $result['version'][ $key ];
  • sites/trunk/api.wordpress.org/public_html/core/browse-happy/1.0/tests/phpunit/tests/browse-happy.php

    r5979 r5980  
    450450            ],
    451451
     452            // Unknown
     453
     454            [
     455                'Dalvik/1.6.0 (Linux; U; Android 4.1.1; BroadSign Xpress 1.0.14 B- (720) Build/JRO03H)',
     456                'Android unknown',
     457            ],
     458            [ // on Galaxy SIII
     459                'Dalvik/1.6.0 (Linux; U; Android 4.4.2; SCH-I535 Build/KOT49H)',
     460                'Android unknown',
     461            ],
     462            [
     463                'Mozilla/5.0 (iPhone; CPU iPhone OS 9_3_2 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Mobile/13F69 [FBAN/FBIOS;FBAV/59.0.0.51.142;FBBV/33266808;FBRV/0;FBDV/iPhone7,1;FBMD/iPhone;FBSN/iPhone OS;FBSV/9.3.2;FBSS/3;FBCR/Telkomsel;FBID/phone;FBLC/en_US;FBOP/5] evaliant',
     464                'iPhone unknown', // Actually: iPhone Facebook App 59.0.0.51.142
     465            ],
     466            [
     467                'Nokia-MIT-Browser/3.0',
     468                'unknown', // It's really a Nokia Browser, but not critical to recognize as such.
     469            ],
     470
    452471        ];
    453472    }
     
    463482        $result = $parsed['platform'] . ' ' . $parsed['name'] . ' ' . $parsed['version'];
    464483
    465         $this->assertEquals( $expected, $result );
     484        $this->assertEquals( $expected, trim( $result ) );
    466485    }
    467486
Note: See TracChangeset for help on using the changeset viewer.