fix issue comparison when checking if a url includes a key domain
This commit is contained in:
parent
bde0b97935
commit
1a512fc260
1 changed files with 16 additions and 16 deletions
|
@ -9,13 +9,13 @@ var clone = require('clone'),
|
||||||
express = require('express');
|
express = require('express');
|
||||||
|
|
||||||
|
|
||||||
module.exports = function(options, repo, params, id, reportTiles, reportFont) {
|
module.exports = function (options, repo, params, id, reportTiles, reportFont) {
|
||||||
var app = express().disable('x-powered-by');
|
var app = express().disable('x-powered-by');
|
||||||
|
|
||||||
var styleFile = path.resolve(options.paths.styles, params.style);
|
var styleFile = path.resolve(options.paths.styles, params.style);
|
||||||
|
|
||||||
var styleJSON = clone(require(styleFile));
|
var styleJSON = clone(require(styleFile));
|
||||||
Object.keys(styleJSON.sources).forEach(function(name) {
|
Object.keys(styleJSON.sources).forEach(function (name) {
|
||||||
var source = styleJSON.sources[name];
|
var source = styleJSON.sources[name];
|
||||||
var url = source.url;
|
var url = source.url;
|
||||||
if (url && url.lastIndexOf('mbtiles:', 0) === 0) {
|
if (url && url.lastIndexOf('mbtiles:', 0) === 0) {
|
||||||
|
@ -35,7 +35,7 @@ module.exports = function(options, repo, params, id, reportTiles, reportFont) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
styleJSON.layers.forEach(function(obj) {
|
styleJSON.layers.forEach(function (obj) {
|
||||||
if (obj['type'] == 'symbol') {
|
if (obj['type'] == 'symbol') {
|
||||||
var fonts = (obj['layout'] || {})['text-font'];
|
var fonts = (obj['layout'] || {})['text-font'];
|
||||||
if (fonts && fonts.length) {
|
if (fonts && fonts.length) {
|
||||||
|
@ -64,7 +64,7 @@ module.exports = function(options, repo, params, id, reportTiles, reportFont) {
|
||||||
|
|
||||||
repo[id] = styleJSON;
|
repo[id] = styleJSON;
|
||||||
|
|
||||||
var isWhitelistedUrl = function(url) {
|
var isWhitelistedUrl = function (url) {
|
||||||
if (!options.auth || !Array.isArray(options.auth.keyDomains) || options.auth.keyDomains.length === 0) {
|
if (!options.auth || !Array.isArray(options.auth.keyDomains) || options.auth.keyDomains.length === 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ module.exports = function(options, repo, params, id, reportTiles, reportFont) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (url.includes(keyDomain) === 0) {
|
if (url.includes(keyDomain)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ module.exports = function(options, repo, params, id, reportTiles, reportFont) {
|
||||||
};
|
};
|
||||||
|
|
||||||
var styleJSON_ = clone(styleJSON);
|
var styleJSON_ = clone(styleJSON);
|
||||||
Object.keys(styleJSON_.sources).forEach(function(name) {
|
Object.keys(styleJSON_.sources).forEach(function (name) {
|
||||||
var source = styleJSON_.sources[name];
|
var source = styleJSON_.sources[name];
|
||||||
source.url = fixUrl(source.url);
|
source.url = fixUrl(source.url);
|
||||||
});
|
});
|
||||||
|
@ -131,7 +131,7 @@ module.exports = function(options, repo, params, id, reportTiles, reportFont) {
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/' + id + '/sprite:scale(@[23]x)?\.:format([\\w]+)',
|
app.get('/' + id + '/sprite:scale(@[23]x)?\.:format([\\w]+)',
|
||||||
function(req, res, next) {
|
function (req, res, next) {
|
||||||
if (!spritePath) {
|
if (!spritePath) {
|
||||||
return res.status(404).send('File not found');
|
return res.status(404).send('File not found');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue