diff --git a/js/ext/angular/test/service/ionicPlatform.unit.js b/js/ext/angular/test/service/ionicPlatform.unit.js index 95c1cf6013..bcc427a3af 100644 --- a/js/ext/angular/test/service/ionicPlatform.unit.js +++ b/js/ext/angular/test/service/ionicPlatform.unit.js @@ -33,6 +33,9 @@ describe('Ionic Platform Service', function() { ionic.Platform.setVersion('1'); expect(ionic.Platform.version()).toEqual(1.0); + ionic.Platform.setVersion('0.1'); + expect(ionic.Platform.version()).toEqual(0.1); + ionic.Platform.setVersion(' '); expect(ionic.Platform.version()).toEqual(0); diff --git a/js/utils/platform.js b/js/utils/platform.js index e19ccfb881..49a85aa523 100644 --- a/js/utils/platform.js +++ b/js/utils/platform.js @@ -44,31 +44,27 @@ this.platforms = []; this.grade = 'a'; - var v = this.version().toString(); - if(v.indexOf('.') > 0) { - v = v.replace('.', '_'); - } else { - v += '_0'; - } + if(this.isCordova()) this.platforms.push('cordova'); + if(this.isIPad()) this.platforms.push('ipad'); - if(this.isCordova()) { - this.platforms.push('cordova'); - } - if(this.isIOS()) { - this.platforms.push('ios'); - this.platforms.push('ios' + v.split('_')[0]); - this.platforms.push('ios' + v); - } - if(this.isIPad()) { - this.platforms.push('ipad'); - } - if(this.isAndroid()) { - this.platforms.push('android'); - this.platforms.push('android' + v.split('_')[0]); - this.platforms.push('android' + v); + var platform = this.platform(); + if(platform) { + this.platforms.push(platform); - if(platformVersion > 0 && platformVersion < 4.4) { - this.grade = (platformVersion < 4 ? 'c' : 'b'); + var version = this.version(); + if(version) { + var v = version.toString(); + if(v.indexOf('.') > 0) { + v = v.replace('.', '_'); + } else { + v += '_0'; + } + this.platforms.push(platform + v.split('_')[0]); + this.platforms.push(platform + v); + + if(this.isAndroid() && version < 4.4) { + this.grade = (version < 4 ? 'c' : 'b'); + } } } },