From 713e53c41a840ae1e66cb9a36e06e0e9361285bd Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Thu, 12 Oct 2023 00:43:42 +0200 Subject: [PATCH] Fix: background layer csp fixe --- scripts/generateLayouts.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/scripts/generateLayouts.ts b/scripts/generateLayouts.ts index 17805270d8..c6ec058f59 100644 --- a/scripts/generateLayouts.ts +++ b/scripts/generateLayouts.ts @@ -233,16 +233,31 @@ async function eliUrls(): Promise { 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(