diff --git a/www/js/app.js b/www/js/app.js index cedd5eed75c305fed2ce174e4781a44721b4d967..eaf82f55cbbdf60f4807fc294994f9477927ace6 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -310,6 +310,11 @@ angular.module('cesium', ['ionic', 'ionic-material', 'ngMessages', 'pascalprecht $rootScope.walletData = csWallet.data; $rootScope.device = Device; + // Compute the root path + var hashIndex = $window.location.href.indexOf('#'); + $rootScope.rootPath = (hashIndex != -1) ? $window.location.href.substr(0, hashIndex) : $window.location.href; + console.debug('[app] Detecting root path: ' + $rootScope.rootPath); + // removeIf(device) // Automatic redirection to large state (if define) $rootScope.$on('$stateChangeStart', function (event, next, nextParams, fromState) { @@ -321,25 +326,16 @@ angular.module('cesium', ['ionic', 'ionic-material', 'ngMessages', 'pascalprecht } } }); - // endRemoveIf(device) - // Force redirection to HTTPS - if (csConfig.httpsMode === true || csConfig.httpsMode === "true" || csConfig.httpsMode === 'force') { + // Automatic redirection to HTTPS + if ((csConfig.httpsMode == true || csConfig.httpsMode === 'force') && + $window.location.protocol != 'https:') { $rootScope.$on('$stateChangeStart', function (event, next, nextParams, fromState) { - if($window.location.protocol != 'https:') { - var href = $window.location.href; - var hashIndex = href.indexOf('#'); - var rootPath = (hashIndex != -1) ? href.substr(0, hashIndex) : href; - var path = 'https' + rootPath.substr(4) + $state.href(next, nextParams); - if (csConfig.httpsModeDebug) { - console.debug('[httpsMode] --- Should redirect to: ' + path); - } - else { - $window.location.href = path; - } - } + var path = 'https' + $rootScope.rootPath.substr(4) + $state.href(next, nextParams); + $window.location.href = path; }); } + // endRemoveIf(device) // Update some translations, when locale changed function onLocaleChange() { diff --git a/www/js/controllers/wallet-controllers.js b/www/js/controllers/wallet-controllers.js index 91e1b0a8d25c4a7ae7032e304325cd05f87a3629..0b12841593abec743420a2f1936a5ce248448fbc 100644 --- a/www/js/controllers/wallet-controllers.js +++ b/www/js/controllers/wallet-controllers.js @@ -465,7 +465,8 @@ function WalletController($scope, $q, $ionicPopup, $timeout, $state, $scope.hideActionsPopover(); var title = $scope.formData.name || $scope.formData.uid || $scope.formData.pubkey; - var url = $state.href('app.wot_identity', {pubkey: $scope.formData.pubkey, uid: $scope.formData.name || $scope.formData.uid}, {absolute: true}); + // Use rootPath (fix #390) + var url = $rootScope.rootPath + $state.href('app.wot_identity', {pubkey: $scope.formData.pubkey, uid: $scope.formData.name || $scope.formData.uid}); UIUtils.popover.share(event, { bindings: { url: url, diff --git a/www/js/controllers/wot-controllers.js b/www/js/controllers/wot-controllers.js index af33f1e0976110d4ac8fe009c96da5c8800a989f..bfc74d37a233bc4df6d9bfda76cbd3868ab5d440 100644 --- a/www/js/controllers/wot-controllers.js +++ b/www/js/controllers/wot-controllers.js @@ -807,7 +807,8 @@ function WotIdentityAbstractController($scope, $rootScope, $state, $translate, $ $scope.showSharePopover = function(event) { var title = $scope.formData.name || $scope.formData.uid || $scope.formData.pubkey; - var url = $state.href('app.wot_identity', {pubkey: $scope.formData.pubkey, uid: $scope.formData.uid}, {absolute: true}); + // Use rootPath (fix #390) + var url = $rootScope.rootPath + $state.href('app.wot_identity', {pubkey: $scope.formData.pubkey, uid: $scope.formData.uid}); UIUtils.popover.share(event, { bindings: { url: url, diff --git a/www/plugins/es/js/controllers/market-controllers.js b/www/plugins/es/js/controllers/market-controllers.js index b1b1650d779fbfa78409df9896b6f5752ea0388f..e7fa60c7920ec2cf0fdaadd629bedb96d9bcc41c 100644 --- a/www/plugins/es/js/controllers/market-controllers.js +++ b/www/plugins/es/js/controllers/market-controllers.js @@ -552,7 +552,7 @@ function ESMarketRecordViewController($scope, $anchorScroll, $ionicPopover, $sta $scope.hideActionsPopover(); var title = $scope.formData.title; - var url = $state.href('app.market_view_record', {title: title, id: $scope.id}, {absolute: true}); + var url = $rootScope.rootPath + $state.href('app.market_view_record', {title: title, id: $scope.id}); UIUtils.popover.share(event, { bindings: { url: url, diff --git a/www/plugins/es/js/controllers/registry-controllers.js b/www/plugins/es/js/controllers/registry-controllers.js index e0cc8f5abee2f7a10ea8218525a42e5b6754f5fe..32eed77a8ebd4a7e27ddc5d865a0f8da502e1dd4 100644 --- a/www/plugins/es/js/controllers/registry-controllers.js +++ b/www/plugins/es/js/controllers/registry-controllers.js @@ -518,7 +518,7 @@ function ESRegistryRecordViewController($scope, $state, $q, $timeout, $ionicPopo $scope.showSharePopover = function(event) { $scope.hideActionsPopover(); var title = $scope.formData.title; - var url = $state.href('app.registry_view_record', {title: title, id: $scope.id}, {absolute: true}); + var url = $rootScope.rootPath + $state.href('app.registry_view_record', {title: title, id: $scope.id}); UIUtils.popover.share(event, { bindings: { url: url,