Skip to content

Commit

Permalink
Merge pull request #109 from ecaldwell/master
Browse files Browse the repository at this point in the history
fixed mixed content error when copying feature services
  • Loading branch information
ecaldwell committed Nov 30, 2015
2 parents 4df909b + 34fb4cd commit 7c4b5a6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
12 changes: 8 additions & 4 deletions src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
});
Expand Down
9 changes: 9 additions & 0 deletions src/js/portal/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};
});

0 comments on commit 7c4b5a6

Please sign in to comment.