Major refactoring of the urls (#5)
This commit is contained in:
14
src/utils.js
14
src/utils.js
@@ -1,7 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
module.exports.getTileUrls = function(
|
||||
protocol, domains, host, path, tilePath, format, key) {
|
||||
module.exports.getTileUrls = function(req, domains, path, format) {
|
||||
|
||||
if (domains) {
|
||||
if (domains.constructor === String && domains.length > 0) {
|
||||
@@ -9,19 +8,16 @@ module.exports.getTileUrls = function(
|
||||
}
|
||||
}
|
||||
if (!domains || domains.length == 0) {
|
||||
domains = [host];
|
||||
domains = [req.headers.host];
|
||||
}
|
||||
|
||||
var key = req.query.key;
|
||||
var query = (key && key.length > 0) ? ('?key=' + key) : '';
|
||||
if (path == '/') {
|
||||
path = '';
|
||||
}
|
||||
|
||||
var uris = [];
|
||||
domains.forEach(function(domain) {
|
||||
uris.push(protocol + '://' + domain + path +
|
||||
tilePath.replace('{format}', format).replace(/\/+/g, '/') +
|
||||
query);
|
||||
uris.push(req.protocol + '://' + domain + '/' + path +
|
||||
'/{z}/{x}/{y}.' + format + query);
|
||||
});
|
||||
|
||||
return uris;
|
||||
|
||||
Reference in New Issue
Block a user