diff options
author | Sam Matthews <matthews.sam@gmail.com> | 2016-10-03 10:08:17 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-10-03 10:08:17 -0700 |
commit | 280fd8c28ed670418954e0a6e2f26292419103d6 (patch) | |
tree | 78d5978251419d5b3f89f208ede4a2f9c4b0ee89 /src/mbgl/util | |
parent | 4bbdb448fd619ae55a9366556923a5d1aaf8cee7 (diff) | |
download | qtlocation-mapboxgl-280fd8c28ed670418954e0a6e2f26292419103d6.tar.gz |
[core] Preserve non-access_token query parameters in canonicalizeTileURL
Diffstat (limited to 'src/mbgl/util')
-rw-r--r-- | src/mbgl/util/mapbox.cpp | 11 |
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; } |