diff --git a/ionic/components/app/app.js b/ionic/components/app/app.js index 57406b3a2b..936b94d4fc 100644 --- a/ionic/components/app/app.js +++ b/ionic/components/app/app.js @@ -42,7 +42,7 @@ export class IonicApp { return this._ua; } - matchesQuery(queryValue) { + matchQuery(queryValue) { let val = this.query('ionicplatform'); if (val) { let valueSplit = val.toLowerCase().split(';'); @@ -55,17 +55,19 @@ export class IonicApp { return false; } - matchesUserAgent(userAgentExpression) { - let rx = new RegExp(userAgentExpression, 'i'); - return rx.test(this._ua); + matchUserAgent(userAgentExpression) { + if (this._ua) { + let rx = new RegExp(userAgentExpression, 'i'); + return rx.exec(this._ua); + } } - matchesPlatform(queryValue, userAgentExpression) { + isPlatform(queryValue, userAgentExpression) { if (!userAgentExpression) { userAgentExpression = queryValue; } - return this.matchesQuery(queryValue) || - this.matchesUserAgent(userAgentExpression); + return (this.matchQuery(queryValue)) || + (this.matchUserAgent(userAgentExpression) !== null); } width(val) { diff --git a/ionic/platform/registry.js b/ionic/platform/registry.js index 1c6bff6f5e..15a7552c5a 100644 --- a/ionic/platform/registry.js +++ b/ionic/platform/registry.js @@ -55,7 +55,7 @@ Platform.register({ mode: 'md' }, isMatch(app) { - return app.matchesPlatform('android'); + return app.isPlatform('android'); } }); @@ -75,7 +75,11 @@ Platform.register({ // SLEDGEHAMMER OVERRIDE FOR NOW return true; - return app.matchesPlatform('ios', 'iphone|ipad|ipod'); + return app.isPlatform('ios', 'iphone|ipad|ipod'); + }, + versionParser: { + let val = app.matchUserAgent('OS (\d+)_(\d+)?'); + console.log(val); }, run() { //Tap.run(); @@ -87,7 +91,7 @@ Platform.register({ name: 'ipad', superset: 'tablet', isMatch(app) { - return app.matchesPlatform('ipad'); + return app.isPlatform('ipad'); } }); @@ -98,7 +102,7 @@ Platform.register({ 'phablet' ], isMatch(app) { - return app.matchesPlatform('iphone'); + return app.isPlatform('iphone'); } }); @@ -114,7 +118,7 @@ Platform.register({ mode: 'wp' }, isMatch(app) { - return app.matchesPlatform('windowsphone', 'windows phone'); + return app.isPlatform('windowsphone', 'windows phone'); } });