From 7d0a985f1dd57ba1c3c2e289ef719b4eec0ce476 Mon Sep 17 00:00:00 2001 From: orangemug Date: Sat, 22 Sep 2018 13:04:12 +0100 Subject: [PATCH] Only replace glyphs key if a replacement exists. --- src/libs/style.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libs/style.js b/src/libs/style.js index 60598f5..4caa357 100644 --- a/src/libs/style.js +++ b/src/libs/style.js @@ -102,9 +102,12 @@ function replaceAccessTokens(mapStyle, opts={}) { }) if (mapStyle.glyphs && mapStyle.glyphs.match(/\.tilehosting\.com/)) { - changedStyle = { - ...changedStyle, - glyphs: mapStyle.glyphs.replace('{key}', getAccessToken("openmaptiles", mapStyle, opts)) + const newAccessToken = getAccessToken("openmaptiles", mapStyle, opts); + if (newAccessToken) { + changedStyle = { + ...changedStyle, + glyphs: mapStyle.glyphs.replace('{key}', newAccessToken) + } } }