Fix: background layer csp fixe

This commit is contained in:
Pieter Vander Vennet 2023-10-12 00:43:42 +02:00
parent 3bd7f5cfe0
commit 713e53c41a

View file

@ -233,16 +233,31 @@ async function eliUrls(): Promise<string[]> {
if (f.properties.type === "vector") {
// We also need to whitelist eventual sources
const styleSpec = await Utils.downloadJsonCached(f.properties.url, 1000 * 120)
for (const key in styleSpec.sources) {
for (const key of Object.keys(styleSpec.sources)) {
const url = styleSpec.sources[key].url
if(!url){
continue
}
let urlClipped = url
if(url.indexOf("?") > 0){
urlClipped = url?.substring(0, url.indexOf("?"))
}
console.log("Source url ",key,url)
urls.push(url)
if(urlClipped.endsWith(".json")){
const tileInfo = await Utils.downloadJsonCached(url, 1000*120)
urls.push(tileInfo["tiles"] ?? [])
}
}
urls.push(...(styleSpec["tiles"] ?? []))
urls.push(styleSpec["sprite"])
urls.push(styleSpec["glyphs"])
}
}
eliUrlsCached = urls
return urls
return Utils.NoNull(urls).sort()
}
async function generateCsp(