Promote https urls over http

This commit is contained in:
Raul Ochoa 2018-01-03 22:18:59 +00:00
parent f7f513a61a
commit 2cda43dc8d
2 changed files with 11 additions and 8 deletions

View File

@ -314,6 +314,9 @@ MapController.prototype.augmentLayergroupData = function () {
}; };
}; };
function getTemplateUrl(url) {
return url.https || url.http;
}
function getTilejson(tiles, grids) { function getTilejson(tiles, grids) {
const tilejson = { const tilejson = {
@ -371,14 +374,14 @@ MapController.prototype.setTilejsonMetadataToLayergroup = function () {
tilejson.vector = getTilejson( tilejson.vector = getTilejson(
this.resourceLocator.getTileUrls(user, vectorResource) this.resourceLocator.getTileUrls(user, vectorResource)
); );
url.vector = this.resourceLocator.getTemplateUrls(user, vectorResource); url.vector = getTemplateUrl(this.resourceLocator.getTemplateUrls(user, vectorResource));
if (!isVectorOnlyMapConfig) { if (!isVectorOnlyMapConfig) {
const rasterResource = `${layergroup.layergroupid}/{z}/{x}/{y}.png`; const rasterResource = `${layergroup.layergroupid}/{z}/{x}/{y}.png`;
tilejson.raster = getTilejson( tilejson.raster = getTilejson(
this.resourceLocator.getTileUrls(user, rasterResource) this.resourceLocator.getTileUrls(user, rasterResource)
); );
url.raster = this.resourceLocator.getTemplateUrls(user, rasterResource); url.raster = getTemplateUrl(this.resourceLocator.getTemplateUrls(user, rasterResource));
} }
} }

View File

@ -179,8 +179,8 @@ describe('tilejson', function() {
const url = metadata.url; const url = metadata.url;
assert.deepEqual(Object.keys(url), ['vector']); assert.deepEqual(Object.keys(url), ['vector']);
assert.ok(url.vector.http.urlTemplate); assert.ok(url.vector.urlTemplate);
assert.ok(url.vector.http.subdomains); assert.ok(url.vector.subdomains);
testClient.drain(done); testClient.drain(done);
}); });
@ -204,11 +204,11 @@ describe('tilejson', function() {
const url = metadata.url; const url = metadata.url;
assert.deepEqual(Object.keys(url), ['vector', 'raster']); assert.deepEqual(Object.keys(url), ['vector', 'raster']);
assert.ok(url.vector.http.urlTemplate); assert.ok(url.vector.urlTemplate);
assert.ok(url.vector.http.subdomains); assert.ok(url.vector.subdomains);
assert.ok(url.raster.http.urlTemplate); assert.ok(url.raster.urlTemplate);
assert.ok(url.raster.http.subdomains); assert.ok(url.raster.subdomains);
testClient.drain(done); testClient.drain(done);
}); });