Skip to content

Commit

Permalink
fix(cli): print UserAgent string verbatim if from an unknown browser
Browse files Browse the repository at this point in the history
output UserAgent string verbatim instead of the unhelpful "Other 0.0.0 (Other)"
  • Loading branch information
tailsu committed Jun 9, 2015
1 parent 1c233a0 commit 9d97226
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var useragent = require('useragent')

exports.browserFullNameToShort = function (fullName) {
var agent = useragent.parse(fullName)
return agent.toAgent() + ' (' + agent.os + ')'
return agent.family !== 'Other' ? agent.toAgent() + ' (' + agent.os + ')' : fullName;
}

exports.isDefined = function (value) {
Expand Down
5 changes: 5 additions & 0 deletions test/unit/browser.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ describe 'Browser', ->
browser = new Browser 'id', fullName, collection, emitter, socket
expect(browser.toString()).to.equal 'Chrome 16.0.912 (Mac OS X 10.6.8)'

it 'should return verbatim user agent string for unrecognized browser', ->
fullName = 'NonexistentBot/1.2.3'
browser = new Browser 'id', fullName, collection, emitter, socket
expect(browser.toString()).to.equal 'NonexistentBot/1.2.3'


#==========================================================================
# Browser.onKarmaError
Expand Down

0 comments on commit 9d97226

Please sign in to comment.