summaryrefslogtreecommitdiff
path: root/src/mbgl
diff options
context:
space:
mode:
authorSam Matthews <matthews.sam@gmail.com>2016-10-03 10:08:17 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-10-03 10:08:17 -0700
commit280fd8c28ed670418954e0a6e2f26292419103d6 (patch)
tree78d5978251419d5b3f89f208ede4a2f9c4b0ee89 /src/mbgl
parent4bbdb448fd619ae55a9366556923a5d1aaf8cee7 (diff)
downloadqtlocation-mapboxgl-280fd8c28ed670418954e0a6e2f26292419103d6.tar.gz
[core] Preserve non-access_token query parameters in canonicalizeTileURL
Diffstat (limited to 'src/mbgl')
-rw-r--r--src/mbgl/util/mapbox.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/mbgl/util/mapbox.cpp b/src/mbgl/util/mapbox.cpp
index 32194754ec..9cf250f7a3 100644
--- a/src/mbgl/util/mapbox.cpp
+++ b/src/mbgl/util/mapbox.cpp
@@ -5,6 +5,7 @@
#include <stdexcept>
#include <vector>
#include <iostream>
+#include <regex>
namespace {
@@ -191,6 +192,16 @@ std::string canonicalizeTileURL(const std::string& url, SourceType type, uint16_
}
result += "." + extension;
+
+ // get the query and remove access_token, if more parameters exist, add them to the final result
+ if (queryIdx != url.length()) {
+ const auto query = url.substr(queryIdx + 1);
+ std::regex re ("&?access_token=([^&]*)");
+ std::string replace = std::regex_replace(query, re, "");
+ std::string subQuery = (replace.find("&") == 0) ? replace.substr(1, replace.length()) : replace;
+ if (subQuery.length() > 0) result += "?" + subQuery;
+ }
+
return result;
}