define(["jquery"], function(jquery) {
    return {
        // Convert an array to a comma separated string.
        arrayToString: function(array) {
            var arrayString;
            jquery.each(array, function(index, arrayValue) {
                if (index === 0) {
                    arrayString = arrayValue;
                } else if (index > 0) {
                    arrayString = arrayString + "," + arrayValue;
                }
            });

            return arrayString;
        },

        // Clean up common issues with user entered portal URLs.
        fixUrl: function(portalUrl) {
            var deferred = jquery.Deferred();
            if (portalUrl === "") {
                // Default to ArcGIS Online.
                portalUrl = "https://www.arcgis.com/";
            } else if (portalUrl.search("/home/") > 0) {
                // Strip the /home endpoint.
                portalUrl = portalUrl.
                substr(0, portalUrl.search("/home/")) + "/";
            } else if (portalUrl.search("/sharing/") > 0) {
                // Strip the /sharing endpoint.
                portalUrl = portalUrl.
                substr(0, portalUrl.search("/sharing/")) + "/";
            } else if (portalUrl.charAt(portalUrl.length - 1) !== "/") {
                // Add the trailing slash.
                portalUrl = portalUrl + "/";
            }

            deferred.resolve(portalUrl);
            return deferred.promise();
        }
    };
});

@@ -1372,16 +1372,209 @@
      %7D%0A%0A
+            if (portalUrl.indexOf(%22http://%22) === 0 && window.location.href.indexOf(%22https://%22) === 0) %7B    %0A                portalUrl = portalUrl.replace(%22http://%22, %22https://%22);%0A            %7D%0A%0A
         

Add automatic upgrade portal url from http to https where appropriate