remove logging statements. when getting tile urls, use the new keyName option
This commit is contained in:
parent
8519b3c5dd
commit
095c175572
5 changed files with 23 additions and 39 deletions
|
@ -172,7 +172,7 @@ module.exports = function(options, repo, params, id, styles) {
|
|||
info.tiles = utils.getTileUrls(req, info.tiles,
|
||||
'data/' + id, info.format, {
|
||||
'pbf': options.pbfAlias
|
||||
});
|
||||
}, options);
|
||||
return res.send(info);
|
||||
});
|
||||
|
||||
|
|
|
@ -736,7 +736,7 @@ module.exports = function(options, repo, params, id, dataResolver) {
|
|||
app.get('/' + id + '.json', function(req, res, next) {
|
||||
var info = clone(tileJSON);
|
||||
info.tiles = utils.getTileUrls(req, info.tiles,
|
||||
'styles/' + id, info.format);
|
||||
'styles/' + id, info.format, null, options);
|
||||
return res.send(info);
|
||||
});
|
||||
|
||||
|
|
|
@ -85,8 +85,6 @@ module.exports = function (options, repo, params, id, reportTiles, reportFont) {
|
|||
|
||||
app.get('/' + id + '/style.json', function (req, res, next) {
|
||||
var fixUrl = function (url, opt_nokey, opt_nostyle) {
|
||||
console.log("URL:", url);
|
||||
console.log("current options:", options);
|
||||
if (!url || (typeof url !== 'string') || (url.indexOf('local://') !== 0 && !isWhitelistedUrl(url))) {
|
||||
return url;
|
||||
}
|
||||
|
@ -99,33 +97,19 @@ module.exports = function (options, repo, params, id, reportTiles, reportFont) {
|
|||
queryParams[options.auth.keyName] = req.query[options.auth.keyName];
|
||||
}
|
||||
|
||||
console.log("params:", queryParams);
|
||||
if (url.indexOf('local://') === 0) {
|
||||
var query = querystring.stringify(queryParams);
|
||||
if (query.length) {
|
||||
query = '?' + query;
|
||||
}
|
||||
|
||||
console.log(url.replace(
|
||||
'local://', req.protocol + '://' + req.headers.host + '/') + query);
|
||||
|
||||
return url.replace(
|
||||
'local://', req.protocol + '://' + req.headers.host + '/') + query;
|
||||
} else { // whitelisted url. might have existing parameters
|
||||
var parsedUrl = nodeUrl.parse(url);
|
||||
console.log("parsed url:", parsedUrl);
|
||||
var parsedQS = querystring.parse(url.query);
|
||||
|
||||
console.log("parsedQS:", parsedQS);
|
||||
var newParams = Object.assign(parsedQS, queryParams);
|
||||
|
||||
console.log("newParams:", newParams);
|
||||
parsedUrl.search = querystring.stringify(parsedQS);
|
||||
|
||||
console.log("new parsed url:", parsedUrl);
|
||||
|
||||
console.log(nodeUrl.format(parsedUrl));
|
||||
|
||||
parsedUrl.search = querystring.unescape(querystring.stringify(parsedQS));
|
||||
return nodeUrl.format(parsedUrl);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -219,7 +219,7 @@ function start(opts) {
|
|||
}
|
||||
info.tiles = utils.getTileUrls(req, info.tiles, path, info.format, {
|
||||
'pbf': options.pbfAlias
|
||||
});
|
||||
}, options);
|
||||
arr.push(info);
|
||||
});
|
||||
return arr;
|
||||
|
@ -305,7 +305,7 @@ function start(opts) {
|
|||
|
||||
var tiles = utils.getTileUrls(
|
||||
req, style.serving_rendered.tiles,
|
||||
'styles/' + id, style.serving_rendered.format);
|
||||
'styles/' + id, style.serving_rendered.format, null, options);
|
||||
style.xyz_link = tiles[0];
|
||||
}
|
||||
});
|
||||
|
@ -335,7 +335,7 @@ function start(opts) {
|
|||
var tiles = utils.getTileUrls(
|
||||
req, data_.tiles, 'data/' + id, data_.format, {
|
||||
'pbf': options.pbfAlias
|
||||
});
|
||||
}, options);
|
||||
data_.xyz_link = tiles[0];
|
||||
}
|
||||
if (data_.filesize) {
|
||||
|
|
|
@ -6,7 +6,7 @@ var path = require('path'),
|
|||
var clone = require('clone'),
|
||||
glyphCompose = require('glyph-pbf-composite');
|
||||
|
||||
module.exports.getTileUrls = function(req, domains, path, format, aliases) {
|
||||
module.exports.getTileUrls = function (req, domains, path, format, aliases, options) {
|
||||
|
||||
if (domains) {
|
||||
if (domains.constructor === String && domains.length > 0) {
|
||||
|
@ -36,8 +36,8 @@ module.exports.getTileUrls = function(req, domains, path, format, aliases) {
|
|||
|
||||
var key = req.query.key;
|
||||
var queryParams = [];
|
||||
if (req.query.key) {
|
||||
queryParams.push('key=' + req.query.key);
|
||||
if (req.query[options.auth.keyName]) {
|
||||
queryParams.push(options.auth.keyName + '=' + req.query);
|
||||
}
|
||||
if (req.query.style) {
|
||||
queryParams.push('style=' + req.query.style);
|
||||
|
|
Loading…
Reference in a new issue