Only replace glyphs key if a replacement exists.

This commit is contained in:
orangemug 2018-09-22 13:04:12 +01:00
parent 805133d10c
commit 7d0a985f1d

View file

@ -102,9 +102,12 @@ function replaceAccessTokens(mapStyle, opts={}) {
}) })
if (mapStyle.glyphs && mapStyle.glyphs.match(/\.tilehosting\.com/)) { if (mapStyle.glyphs && mapStyle.glyphs.match(/\.tilehosting\.com/)) {
const newAccessToken = getAccessToken("openmaptiles", mapStyle, opts);
if (newAccessToken) {
changedStyle = { changedStyle = {
...changedStyle, ...changedStyle,
glyphs: mapStyle.glyphs.replace('{key}', getAccessToken("openmaptiles", mapStyle, opts)) glyphs: mapStyle.glyphs.replace('{key}', newAccessToken)
}
} }
} }