From 4ba6890178a684d3fa826cea94a41c4cb2fd1f4e Mon Sep 17 00:00:00 2001 From: Evan Caldwell Date: Mon, 30 Nov 2015 13:13:18 -0500 Subject: [PATCH 1/2] fixed mixed content error when copying services Copying services registered with http endpoints while running the app in https was causing the browser to reject the request due to mixed content. --- src/js/main.js | 12 ++++++++---- src/js/portal/util.js | 9 +++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/js/main.js b/src/js/main.js index c033658..5887a7f 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -960,6 +960,9 @@ require([ clone.attr("data-id", service.itemId); clone.attr("data-portal", destinationPortal.portalUrl); + // Upgrade the service url to https to prevent mixed content errors. + service.serviceurl = portalUtil.upgradeUrl(service.serviceurl); + // Update the new item's tags to make it easier to trace its origins. var newTags = description.tags; newTags.push("source-" + description.id); @@ -1063,13 +1066,14 @@ require([ if (isSupported(type)) { // Get the full item description and data from the source. portal.itemDescription(id).done(function(description) { -// var thumbnailUrl = portal.portalUrl + "sharing/rest/content/items/" + id + -// "/info/" + description.thumbnail + "?token=" + portal.token; - portal.cacheItem(description); switch (type) { case "Feature Service": + + // Upgrade the service url to https to prevent mixed content errors. + description.url = portalUtil.upgradeUrl(description.url); + + portal.cacheItem(description); portal.serviceDescription(description.url).done(function(serviceDescription) { -// var layers = serviceDescription.layers; var item = jquery.grep(portal.items, function(item) { return (item.id === id); }); diff --git a/src/js/portal/util.js b/src/js/portal/util.js index f9d38b2..12793d8 100644 --- a/src/js/portal/util.js +++ b/src/js/portal/util.js @@ -39,6 +39,15 @@ define(["jquery"], function(jquery) { deferred.resolve(portalUrl); return deferred.promise(); + }, + + // Upgrade a URL from http to https. + upgradeUrl: function(url) { + if (url.indexOf("http://") === 0 && window.location.href.indexOf("https://") === 0) { + url = url.replace("http://", "https://"); + } + + return url; } }; }); From 34fb4cde361bb64dae85fb5efbb08b4797d98cf3 Mon Sep 17 00:00:00 2001 From: Evan Caldwell Date: Mon, 30 Nov 2015 14:57:12 -0500 Subject: [PATCH 2/2] bumped version number --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 92c57f4..0c86374 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "ago-assistant", "title": "ArcGIS Online Assistant", "description": "A swiss army knife for your ArcGIS Online and Portal for ArcGIS accounts.", - "version": "2.2.5", + "version": "2.2.6", "author": "Evan Caldwell", "homepage": "https://github.com/Esri/ago-assistant", "repository": {