Skip to content

Commit fb33d03

Browse files
committed
fix: fixes #81
1 parent 5bc78ef commit fb33d03

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

ng-device-detector.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
};
1616

1717
this.isIOS = function () {
18-
return (deviceInfo.os === uaDeviceDetector.OS.IOS || deviceInfo.device === uaDeviceDetector.DEVICES.I_POD ||
18+
return (deviceInfo.os === uaDeviceDetector.OS.IOS || deviceInfo.device === uaDeviceDetector.DEVICES.I_POD ||
1919
deviceInfo.device === uaDeviceDetector.DEVICES.IPHONE);
2020
};
2121
}
@@ -35,8 +35,8 @@
3535
reTree
3636
) {
3737
var ua = $window.navigator.userAgent;
38-
var deviceInfo = uaDeviceDetector.parseUserAgent(ua);
39-
deviceInfo.parseUserAgent = uaDeviceDetector.parseUserAgent;
38+
var deviceInfo = uaDeviceDetector.parseUserAgent(ua, customDetectors);
39+
deviceInfo.parseUserAgent = function (ua) { return uaDeviceDetector.parseUserAgent(ua, customDetectors) };
4040
return deviceInfo;
4141
}];
4242
}

test/unit.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,12 @@ describe("ng-device-detector", function () {
5252
// Issue 72
5353
describe("Test custom UA string parsing", function () {
5454
it("Should parse the specified UA", function () {
55-
loadDetector("");
56-
var deviceInfo = deviceDetector.parseUserAgent("Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36");
55+
loadDetector("Custom", function(deviceDetectorProvider) {
56+
deviceDetectorProvider.addCustom('MY_CUSTOM', {
57+
and: ['\\bCustom\\b']
58+
});
59+
});
60+
var deviceInfo = deviceDetector.parseUserAgent("Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36 Custom");
5761
expect(deviceDetector.browser).toBe("unknown");
5862
expect(deviceDetector.os).toBe("unknown");
5963
expect(deviceDetector.device).toBe("unknown");
@@ -65,6 +69,7 @@ describe("ng-device-detector", function () {
6569
expect(deviceInfo.isMobile()).toBeFalsy();
6670
expect(deviceInfo.isTablet()).toBeFalsy();
6771
expect(deviceInfo.isDesktop()).toBeTruthy();
72+
expect(deviceDetector.custom.MY_CUSTOM).toBeTruthy();
6873
});
6974
});
7075
});

0 commit comments

Comments
 (0)