summaryrefslogtreecommitdiff
path: root/src/mbgl/util/token.hpp
diff options
context:
space:
mode:
authorRandall Lee <randall.lee@mapbox.com>2018-05-22 14:09:36 -0400
committerGitHub <noreply@github.com>2018-05-22 14:09:36 -0400
commitd858cb783b499a1cc77b48a0faee137ca5e6a423 (patch)
tree5c36c353730e3050d44e472545519c0429723266 /src/mbgl/util/token.hpp
parentf93d722458be62d567aa152711a014ef51a90193 (diff)
parent60505b03174b5ec02ae723beafa7683f6ed54a62 (diff)
downloadqtlocation-mapboxgl-upstream/rclee-async-setup.tar.gz
Merge branch 'master' into rclee-async-setupupstream/rclee-async-setup
Diffstat (limited to 'src/mbgl/util/token.hpp')
-rw-r--r--src/mbgl/util/token.hpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/mbgl/util/token.hpp b/src/mbgl/util/token.hpp
index 149661e47e..dea12f9412 100644
--- a/src/mbgl/util/token.hpp
+++ b/src/mbgl/util/token.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include <mbgl/util/optional.hpp>
+
#include <map>
#include <string>
#include <algorithm>
@@ -25,7 +27,14 @@ std::string replaceTokens(const std::string &source, const Lookup &lookup) {
if (pos != end) {
for (brace++; brace != end && tokenReservedChars.find(*brace) == std::string::npos; brace++);
if (brace != end && *brace == '}') {
- result.append(lookup({ pos + 1, brace }));
+ std::string key { pos + 1, brace };
+ if (optional<std::string> replacement = lookup(key)) {
+ result.append(*replacement);
+ } else {
+ result.append("{");
+ result.append(key);
+ result.append("}");
+ }
pos = brace + 1;
} else {
result.append(pos, brace);