From 0dfc2ce44f19552570ccdfeb3707a665d757fcba Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Fri, 17 Apr 2015 09:02:30 -0600 Subject: [PATCH 1/4] Avoid protocol relative URLs These fail to load in contexts where the "file protocol" is used (e.g. PhantomJS). --- examples/overviewmap-custom.js | 2 +- src/ol/source/mapquestsource.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/overviewmap-custom.js b/examples/overviewmap-custom.js index c9aa0c181d..e3fe0926a4 100644 --- a/examples/overviewmap-custom.js +++ b/examples/overviewmap-custom.js @@ -14,7 +14,7 @@ var overviewMapControl = new ol.control.OverviewMap({ layers: [ new ol.layer.Tile({ source: new ol.source.OSM({ - 'url': '//{a-c}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png' + 'url': 'https://{a-c}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png' }) }) ], diff --git a/src/ol/source/mapquestsource.js b/src/ol/source/mapquestsource.js index df021a5575..d687fc5aae 100644 --- a/src/ol/source/mapquestsource.js +++ b/src/ol/source/mapquestsource.js @@ -40,7 +40,7 @@ ol.source.MapQuest = function(opt_options) { goog.base(this, { attributions: layerConfig.attributions, crossOrigin: 'anonymous', - logo: '//developer.mapquest.com/content/osm/mq_logo.png', + logo: 'https://developer.mapquest.com/content/osm/mq_logo.png', maxZoom: layerConfig.maxZoom, opaque: true, tileLoadFunction: options.tileLoadFunction, From b22f3c68298ca976ed6ef9d7b8cd1cbe02c29a55 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Fri, 17 Apr 2015 09:08:49 -0600 Subject: [PATCH 2/4] Use HTTPS where available --- src/ol/source/bingmapssource.js | 8 +++----- src/ol/source/mapquestsource.js | 4 +--- src/ol/source/osmsource.js | 4 +--- src/ol/source/stamensource.js | 7 ++----- 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/ol/source/bingmapssource.js b/src/ol/source/bingmapssource.js index f1eb3f415d..948f8537cb 100644 --- a/src/ol/source/bingmapssource.js +++ b/src/ol/source/bingmapssource.js @@ -4,7 +4,6 @@ goog.require('goog.Uri'); goog.require('goog.array'); goog.require('goog.asserts'); goog.require('goog.net.Jsonp'); -goog.require('ol'); goog.require('ol.Attribution'); goog.require('ol.TileRange'); goog.require('ol.TileUrlFunction'); @@ -49,15 +48,14 @@ ol.source.BingMaps = function(options) { */ this.maxZoom_ = goog.isDef(options.maxZoom) ? options.maxZoom : -1; - var protocol = ol.IS_HTTPS ? 'https:' : 'http:'; var uri = new goog.Uri( - protocol + '//dev.virtualearth.net/REST/v1/Imagery/Metadata/' + + 'https://dev.virtualearth.net/REST/v1/Imagery/Metadata/' + options.imagerySet); var jsonp = new goog.net.Jsonp(uri, 'jsonp'); jsonp.send({ 'include': 'ImageryProviders', - 'uriScheme': ol.IS_HTTPS ? 'https' : 'http', + 'uriScheme': 'https', 'key': options.key }, goog.bind(this.handleImageryMetadataResponse, this)); @@ -93,7 +91,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse = } var brandLogoUri = response.brandLogoUri; - if (ol.IS_HTTPS && brandLogoUri.indexOf('https') == -1) { + if (brandLogoUri.indexOf('https') == -1) { brandLogoUri = brandLogoUri.replace('http', 'https'); } //var copyright = response.copyright; // FIXME do we need to display this? diff --git a/src/ol/source/mapquestsource.js b/src/ol/source/mapquestsource.js index d687fc5aae..3a56e3de8d 100644 --- a/src/ol/source/mapquestsource.js +++ b/src/ol/source/mapquestsource.js @@ -1,7 +1,6 @@ goog.provide('ol.source.MapQuest'); goog.require('goog.asserts'); -goog.require('ol'); goog.require('ol.Attribution'); goog.require('ol.source.OSM'); goog.require('ol.source.XYZ'); @@ -32,9 +31,8 @@ ol.source.MapQuest = function(opt_options) { */ this.layer_ = options.layer; - var protocol = ol.IS_HTTPS ? 'https:' : 'http:'; var url = goog.isDef(options.url) ? options.url : - protocol + '//otile{1-4}-s.mqcdn.com/tiles/1.0.0/' + + 'https://otile{1-4}-s.mqcdn.com/tiles/1.0.0/' + this.layer_ + '/{z}/{x}/{y}.jpg'; goog.base(this, { diff --git a/src/ol/source/osmsource.js b/src/ol/source/osmsource.js index 7f992f136e..bd7ed7e6d3 100644 --- a/src/ol/source/osmsource.js +++ b/src/ol/source/osmsource.js @@ -1,6 +1,5 @@ goog.provide('ol.source.OSM'); -goog.require('ol'); goog.require('ol.Attribution'); goog.require('ol.source.XYZ'); @@ -29,9 +28,8 @@ ol.source.OSM = function(opt_options) { var crossOrigin = goog.isDef(options.crossOrigin) ? options.crossOrigin : 'anonymous'; - var protocol = ol.IS_HTTPS ? 'https:' : 'http:'; var url = goog.isDef(options.url) ? - options.url : protocol + '//{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png'; + options.url : 'https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png'; goog.base(this, { attributions: attributions, diff --git a/src/ol/source/stamensource.js b/src/ol/source/stamensource.js index 2805a5fccd..ed34cb7988 100644 --- a/src/ol/source/stamensource.js +++ b/src/ol/source/stamensource.js @@ -1,7 +1,6 @@ goog.provide('ol.source.Stamen'); goog.require('goog.asserts'); -goog.require('ol'); goog.require('ol.Attribution'); goog.require('ol.source.OSM'); goog.require('ol.source.XYZ'); @@ -99,11 +98,9 @@ ol.source.Stamen = function(options) { 'known layer configured'); var layerConfig = ol.source.StamenLayerConfig[options.layer]; - var root = ol.IS_HTTPS ? 'https://stamen-tiles-{a-d}.a.ssl.fastly.net/' : - 'http://{a-d}.tile.stamen.com/'; var url = goog.isDef(options.url) ? options.url : - root + options.layer + '/{z}/{x}/{y}.' + - layerConfig.extension; + 'https://stamen-tiles-{a-d}.a.ssl.fastly.net/' + options.layer + + '/{z}/{x}/{y}.' + layerConfig.extension; goog.base(this, { attributions: ol.source.Stamen.ATTRIBUTIONS, From 3b1c33ded5b47f47a8d8c3f6cc2b80751e04d31b Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Fri, 17 Apr 2015 09:14:59 -0600 Subject: [PATCH 3/4] Remove unused ol.IS_HTTPS --- src/ol/ol.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/ol/ol.js b/src/ol/ol.js index 417a0cde6c..8996511246 100644 --- a/src/ol/ol.js +++ b/src/ol/ol.js @@ -153,14 +153,6 @@ ol.LEGACY_IE_SUPPORT = false; ol.INITIAL_ATLAS_SIZE = 256; -/** - * The page is loaded using HTTPS. - * @const - * @type {boolean} - */ -ol.IS_HTTPS = goog.global.location.protocol === 'https:'; - - /** * Whether the current browser is legacy IE * @const From ad95efd795f71abb982e918e946d9624a0d98d8b Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Fri, 17 Apr 2015 10:40:59 -0600 Subject: [PATCH 4/4] Use HTTP for {a-c}.tile.opencyclemap.org While the resource is available via HTTPS, it currently generates NET::ERR_CERT_COMMON_NAME_INVALID. --- examples/overviewmap-custom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/overviewmap-custom.js b/examples/overviewmap-custom.js index e3fe0926a4..abc13e842b 100644 --- a/examples/overviewmap-custom.js +++ b/examples/overviewmap-custom.js @@ -14,7 +14,7 @@ var overviewMapControl = new ol.control.OverviewMap({ layers: [ new ol.layer.Tile({ source: new ol.source.OSM({ - 'url': 'https://{a-c}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png' + 'url': 'http://{a-c}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png' }) }) ],