-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Persist querystrings in mapbox:// resource urls to API requests #6182
Conversation
@jakepruitt, thanks for your PR! By analyzing this pull request, we identified @jfirebaugh, @yhahn and @1ec5 to be potential reviewers. |
@@ -44,7 +44,13 @@ std::string normalizeSourceURL(const std::string& url, const std::string& access | |||
throw std::runtime_error("You must provide a Mapbox API access token for Mapbox tile sources"); | |||
} | |||
|
|||
return baseURL + "v4/" + url.substr(protocol.length()) + ".json?access_token=" + accessToken + "&secure"; | |||
auto queryIdx = url.find("?"); | |||
std::string query = ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Omit = ""
-- it'll be initialized to an empty string automatically.
373b764
to
d4098d7
Compare
std::string query; | ||
if (queryIdx != std::string::npos) { | ||
query = url.substr(queryIdx + 1, url.length() - queryIdx + 1); | ||
if (query.length() > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally if (!query.empty()) {
is better practice since it is faster than query.size()
.
d4098d7
to
17e6591
Compare
Made a refactoring pass and rebased this /cc @jakepruitt. Ready for review by others, notably @jfirebaugh @1ec5 |
@@ -11,15 +11,16 @@ namespace util { | |||
namespace mapbox { | |||
|
|||
const std::string protocol = "mapbox://"; | |||
const std::size_t protocol_length = protocol.length(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Camel case please.
Carries over any query strings from mapbox://-prefixed styles urls, source urls and tile urls to the api.mapbox.com requests.
17e6591
to
9134ddd
Compare
Thank you @jfirebaugh! |
Carries over any query strings from
mapbox://
-prefixed styles urls, source urls and tile urls to theapi.mapbox.com
requests.cc/ @mapsam @1ec5 @jfirebaugh @yhahn @GretaCB