Skip to content

Commit 0f4b3ff

Browse files
authored
Merge pull request #4957 from HSLdevcom/allzones-to-cdn
Fetch assembed zones via CDN
2 parents ccfc8c5 + 840f8b9 commit 0f4b3ff

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

app/config.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ if (defaultConfig.themeMap) {
2121

2222
let allZones;
2323
export function setAssembledZones(zoneLayer) {
24-
allZones = zoneLayer;
24+
allZones = { ...zoneLayer };
2525
}
2626

2727
function addMetaData(config) {
@@ -81,6 +81,13 @@ function addMetaData(config) {
8181
}
8282
}
8383

84+
function mapGeoJsonPaths(url, config) {
85+
const appPathPrefix = config.URL.ASSET_URL || '';
86+
const mapUrl = u =>
87+
u.startsWith('http') || u.startsWith('//') ? u : appPathPrefix + u;
88+
return typeof url === 'string' ? mapUrl(url) : url.map(u => mapUrl(u));
89+
}
90+
8491
export function getNamedConfiguration(configName) {
8592
if (!configs[configName]) {
8693
let additionalConfig;
@@ -126,13 +133,10 @@ export function getNamedConfiguration(configName) {
126133

127134
addMetaData(config); // add dynamic metadata content
128135

129-
const appPathPrefix = config.URL.ASSET_URL || '';
130-
if (config.geoJson && Array.isArray(config.geoJson.layers)) {
136+
if (config.geoJson?.layers) {
131137
for (let i = 0; i < config.geoJson.layers.length; i++) {
132138
const layer = config.geoJson.layers[i];
133-
if (layer.url.indexOf('http') !== 0) {
134-
layer.url = appPathPrefix + layer.url;
135-
}
139+
layer.url = mapGeoJsonPaths(layer.url, config);
136140
}
137141
}
138142
configs[configName] = config;
@@ -143,6 +147,7 @@ export function getNamedConfiguration(configName) {
143147
if (!conf.geoJson?.layers?.find(l => l.name === allZones.name)) {
144148
const zoneLayer = {
145149
...allZones,
150+
url: mapGeoJsonPaths(allZones.url, conf),
146151
isOffByDefault: conf.useAssembledGeoJsonZones === 'isOffByDefault',
147152
};
148153
if (!conf.geoJson) {

app/store/GeoJsonStore.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class GeoJsonStore extends Store {
8787
let id;
8888
let urlArr;
8989
if (Array.isArray(url)) {
90-
[id] = url;
90+
id = `${url[0]}-array`;
9191
urlArr = url;
9292
} else {
9393
id = url;

0 commit comments

Comments
 (0)