@@ -21,7 +21,7 @@ if (defaultConfig.themeMap) {
21
21
22
22
let allZones ;
23
23
export function setAssembledZones ( zoneLayer ) {
24
- allZones = zoneLayer ;
24
+ allZones = { ... zoneLayer } ;
25
25
}
26
26
27
27
function addMetaData ( config ) {
@@ -81,6 +81,13 @@ function addMetaData(config) {
81
81
}
82
82
}
83
83
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
+
84
91
export function getNamedConfiguration ( configName ) {
85
92
if ( ! configs [ configName ] ) {
86
93
let additionalConfig ;
@@ -126,13 +133,10 @@ export function getNamedConfiguration(configName) {
126
133
127
134
addMetaData ( config ) ; // add dynamic metadata content
128
135
129
- const appPathPrefix = config . URL . ASSET_URL || '' ;
130
- if ( config . geoJson && Array . isArray ( config . geoJson . layers ) ) {
136
+ if ( config . geoJson ?. layers ) {
131
137
for ( let i = 0 ; i < config . geoJson . layers . length ; i ++ ) {
132
138
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 ) ;
136
140
}
137
141
}
138
142
configs [ configName ] = config ;
@@ -143,6 +147,7 @@ export function getNamedConfiguration(configName) {
143
147
if ( ! conf . geoJson ?. layers ?. find ( l => l . name === allZones . name ) ) {
144
148
const zoneLayer = {
145
149
...allZones ,
150
+ url : mapGeoJsonPaths ( allZones . url , conf ) ,
146
151
isOffByDefault : conf . useAssembledGeoJsonZones === 'isOffByDefault' ,
147
152
} ;
148
153
if ( ! conf . geoJson ) {
0 commit comments