Skip to content

Commit

Permalink
fix issue #15
Browse files Browse the repository at this point in the history
  • Loading branch information
hgoebl committed Nov 12, 2014
1 parent 5bc9d89 commit d37e670
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
v0.4.3:
date: (snapshot)
changes:
- fix issue #15 (detect crazy Microsoft Mobile OS)

v0.4.2:
date: 2014-10-21
changes:
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mobile-detect",
"version": "0.4.2",
"version": "0.4.3-snapshot",
"description": "Device detection (phone, tablet, desktop, mobile grade, os, versions)",
"homepage": "http://hgoebl.github.io/mobile-detect.js/",
"keywords": [
Expand Down
9 changes: 8 additions & 1 deletion generate/mobile-detect.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ define(function () {
convertPropsToRegExp(mobileDetectRules.tablets);
convertPropsToRegExp(mobileDetectRules.uas);
convertPropsToRegExp(mobileDetectRules.utils);

// copy some patterns to oss0 which are tested first (see issue#15)
mobileDetectRules.oss0 = {
WindowsPhoneOS: mobileDetectRules.oss.WindowsPhoneOS,
WindowsMobileOS: mobileDetectRules.oss.WindowsMobileOS
};
}());

function convertPropsToRegExp(object) {
Expand Down Expand Up @@ -438,7 +444,8 @@ define(function () {
*/
os: function () {
if (this._cache.os === undefined) {
this._cache.os = findMatch(mobileDetectRules.oss, this.ua);
this._cache.os = findMatch(mobileDetectRules.oss0, this.ua) ||
findMatch(mobileDetectRules.oss, this.ua);
}
return this._cache.os;
},
Expand Down
9 changes: 8 additions & 1 deletion mobile-detect.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,12 @@ define(function () {
convertPropsToRegExp(mobileDetectRules.tablets);
convertPropsToRegExp(mobileDetectRules.uas);
convertPropsToRegExp(mobileDetectRules.utils);

// copy some patterns to oss0 which are tested first (see issue#15)
mobileDetectRules.oss0 = {
WindowsPhoneOS: mobileDetectRules.oss.WindowsPhoneOS,
WindowsMobileOS: mobileDetectRules.oss.WindowsMobileOS
};
}());

function convertPropsToRegExp(object) {
Expand Down Expand Up @@ -714,7 +720,8 @@ define(function () {
*/
os: function () {
if (this._cache.os === undefined) {
this._cache.os = findMatch(mobileDetectRules.oss, this.ua);
this._cache.os = findMatch(mobileDetectRules.oss0, this.ua) ||
findMatch(mobileDetectRules.oss, this.ua);
}
return this._cache.os;
},
Expand Down
4 changes: 2 additions & 2 deletions mobile-detect.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mobile-detect",
"version": "0.4.2",
"version": "0.4.3-snapshot",
"description": "Device detection (phone, tablet, desktop, mobile grade, os, versions)",
"main": "mobile-detect.js",
"scripts": {
Expand Down
4 changes: 4 additions & 0 deletions tests/spec/MobileDetectSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ describe("Fixing issues", function () {
expect(aut).toBeTablet(true);
expect(aut).toBeMobile(true);
});
it("should fix issue #15", function () {
var aut = new MobileDetect('Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; Microsoft; Virtual) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537', -1);
expect(aut.os()).toEqual('WindowsMobileOS');
});
});

describe("Feeding w/ ualist", function () {
Expand Down

0 comments on commit d37e670

Please sign in to comment.