Use HTTPS in Meteor.absoluteUrl by default if window.location uses HTTPS.

Another attempt to fix #9879.
This commit is contained in:
Ben Newman
2018-05-12 10:50:16 -04:00
parent 9bf35f60d2
commit dacedda571

View File

@@ -44,11 +44,22 @@ Meteor.absoluteUrl = function (path, options) {
};
// allow later packages to override default options
Meteor.absoluteUrl.defaultOptions = { };
var defaultOptions = Meteor.absoluteUrl.defaultOptions = {};
// available only in a browser environment
var location = typeof window === "object" && window.location;
if (typeof __meteor_runtime_config__ === "object" &&
__meteor_runtime_config__.ROOT_URL)
Meteor.absoluteUrl.defaultOptions.rootUrl = __meteor_runtime_config__.ROOT_URL;
// Make absolute URLs use HTTPS by default if the current window.location
// uses HTTPS. Since this is just a default, it can be overridden by
// passing { secure: false } if necessary.
if (location &&
location.protocol === "https:") {
defaultOptions.secure = true;
}
Meteor._relativeToSiteRootUrl = function (link) {
if (typeof __meteor_runtime_config__ === "object" &&