Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed mixed content error when copying feature services #109

Merged
merged 2 commits into from
Nov 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
};
});