diff --git a/js/utils/platform.js b/js/utils/platform.js index a27b8ddd27b..5f1e86f673b 100644 --- a/js/utils/platform.js +++ b/js/utils/platform.js @@ -247,7 +247,7 @@ platformName = getParameterByName('ionicplatform'); } else if (self.ua.indexOf('Android') > 0) { platformName = ANDROID; - } else if (self.ua.indexOf('iPhone') > -1 || self.ua.indexOf('iPad') > -1 || self.ua.indexOf('iPod') > -1) { + } else if (/iPhone|iPad|iPod/.test(self.ua)) { platformName = IOS; } else if (self.ua.indexOf('Windows Phone') > -1) { platformName = WINDOWS_PHONE; diff --git a/test/unit/angular/service/platform.unit.js b/test/unit/angular/service/platform.unit.js index 0a86724e567..055c47a1e8a 100644 --- a/test/unit/angular/service/platform.unit.js +++ b/test/unit/angular/service/platform.unit.js @@ -86,6 +86,14 @@ describe('Ionic Platform Service', function() { expect(ionic.Platform.version()).toEqual(7.0); }); + it('set ios with iPod user agent', function() { + ionic.Platform.ua = 'Mozilla/5.0 (iPod touch; CPU OS 8_1_3 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B511 Safari/9537.53'; + ionic.Platform.setPlatform(undefined); + ionic.Platform.setVersion(undefined); + expect(ionic.Platform.platform()).toEqual('ios'); + expect(ionic.Platform.version()).toEqual(8.1); + }); + it('should not be iPad from none iPad user agent', function() { ionic.Platform.ua = 'Mozilla/5.0 (iPhone; CPU OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B554a Safari/9537.53'; ionic.Platform.setPlatform(undefined);