diff --git a/src/components/print/PrintDirective.js b/src/components/print/PrintDirective.js index 755d69b312..4283b075e9 100644 --- a/src/components/print/PrintDirective.js +++ b/src/components/print/PrintDirective.js @@ -624,7 +624,7 @@ return parseInt(scale.value); }); var that = this; - $http.jsonp($scope.options.shortenUrl, { + $http.get($scope.options.shortenUrl, { params: { url: gaPermalink.getHref() } diff --git a/src/components/share/ShareDirective.js b/src/components/share/ShareDirective.js index 46799301a0..5fc64ae9e8 100644 --- a/src/components/share/ShareDirective.js +++ b/src/components/share/ShareDirective.js @@ -2,15 +2,13 @@ goog.provide('ga_share_directive'); goog.require('ga_permalink'); - goog.require('ga_urlutils_service'); var module = angular.module('ga_share_directive', [ - 'ga_permalink', - 'ga_urlutils_service' + 'ga_permalink' ]); module.directive('gaShare', - function($http, $window, gaPermalink, gaUrlUtils) { + function($http, $window, gaPermalink) { return { restrict: 'A', scope: { @@ -18,8 +16,7 @@ }, templateUrl: 'components/share/partials/share.html', link: function(scope, element, attrs) { - var shortenUrl = gaUrlUtils.append(scope.options.shortenUrl, - 'cb=JSON_CALLBACK'); + var shortenUrl = scope.options.shortenUrl; scope.qrcodegeneratorPath = scope.options.qrcodegeneratorPath; $('.ga-share-icon').tooltip({ @@ -58,7 +55,7 @@ // Function to shorten url // Make an asynchronous request to url shortener scope.shortenUrl = function() { - $http.jsonp(shortenUrl, { + $http.get(shortenUrl, { params: { url: scope.permalinkValue } diff --git a/src/js/PrintController.js b/src/js/PrintController.js index fa704d5e7c..5e0ea2df1a 100644 --- a/src/js/PrintController.js +++ b/src/js/PrintController.js @@ -13,7 +13,7 @@ encodeURIComponent(printPath), legendUrl: gaGlobalOptions.apiUrl + '/static/images/legends/', qrcodeUrl: gaGlobalOptions.apiUrl + '/qrcodegenerator?url=', - shortenUrl: gaGlobalOptions.apiUrl + '/shorten.json?cb=JSON_CALLBACK', + shortenUrl: gaGlobalOptions.apiUrl + '/shorten.json', markerUrl: gaGlobalOptions.resourceUrl + 'img/marker.png', heightMargin: $('#header').height(), widthMargin: $('#pulldown').width(), diff --git a/src/lib/angularIE9CorsFix.js b/src/lib/angularIE9CorsFix.js index 38541216da..5835851c6b 100644 --- a/src/lib/angularIE9CorsFix.js +++ b/src/lib/angularIE9CorsFix.js @@ -20,12 +20,22 @@ var IE9Fix = function() { isXDomain = function(requestUrl) { // gjn: replaced the whole function. // original is still commented below + var getHostName = function(url) { + var l = window.document.createElement('a'); + l.href = url; + return l.hostname + .replace('http://', '') + .replace('https://', ''); + }; + var host = window.location.origin .replace('http://', '') .replace('https://', ''); - //if host is found, then not XDomain - if (requestUrl.indexOf(host) > -1) { + var requestUrlHost = getHostName(requestUrl); + + //if host are identical, then not XDomain + if (requestUrlHost === host) { return false; } //check for relative url @@ -34,7 +44,7 @@ var IE9Fix = function() { return false; } return true; -/* + /* if (requestUrl[0] === '/') { if (requestUrl.length === 1) { return false;