Skip to content
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.

Detect IE on desktop #10

Merged
merged 3 commits into from
Apr 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function info(){
var tem;
var os;

var match = ua.match(/(opera|chrome|safari|firefox|msie|edge|trident(?=\/))\/?\s*(\d+)/i) || [];
var match = ua.match(/(opera|chrome|safari|firefox|edge|trident(?=\/))\/?\s*(\d+)/i) || [];

if (ua.indexOf('Win') !== -1) {
os = 'Windows';
Expand All @@ -28,6 +28,9 @@ function info(){
if (/iPad|iPhone|iPod/.test(ua)) {
os = 'iOS';
}
if (ua.indexOf('Windows Phone') !== -1) {
os = 'Windows Phone';
}

if (/trident/i.test(match[1])) {
tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
Expand Down
12 changes: 11 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,17 @@ describe('browser-info', function() {
userAgent: 'Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0)'
};

should(info().name).equal('IEMobile');
should(info().os).equal('Windows Phone');
should(info().name).equal('IE');
done();
});

it('should detect IE', function(done) {
GLOBAL.navigator = {
userAgent: 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko'
};

should(info().name).equal('IE');
done();
});
});