From f471f56f74c614255c71eb20ad31c4b116eb772c Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Thu, 4 Dec 2014 14:10:14 -0600 Subject: [PATCH] feat(platforms): allow overriding platform in querystring --- js/utils/platform.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/js/utils/platform.js b/js/utils/platform.js index 94f3110ca2..e4cf3b61c4 100644 --- a/js/utils/platform.js +++ b/js/utils/platform.js @@ -1,5 +1,12 @@ (function(window, document, ionic) { + function getParameterByName(name) { + name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); + var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), + results = regex.exec(location.search); + return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); + } + var IOS = 'ios'; var ANDROID = 'android'; var WINDOWS_PHONE = 'windowsphone'; @@ -206,8 +213,12 @@ * @private */ setPlatform: function(n) { + var override; + if (typeof n != 'undefined' && n !== null && n.length) { platformName = n.toLowerCase(); + } else if(override = getParameterByName('ionicplatform')) { + platformName = override; } else if (this.ua.indexOf('Android') > 0) { platformName = ANDROID; } else if (this.ua.indexOf('iPhone') > -1 || this.ua.indexOf('iPad') > -1 || this.ua.indexOf('iPod') > -1) {