Adding special case for non-fontstack "glyph" resource URLs

- does not prepend /v4/ to api endpoints like /fonts/v1/
- only prepends it to things starting with /fontstack
- solves the problem in #1918
- refs mapbox/mapbox-gl-style-spec#309
This commit is contained in:
jakepruitt
2015-07-23 18:29:12 -04:00
parent 32c7805740
commit 14ba3cfd6a
2 changed files with 6 additions and 1 deletions

View File

@@ -45,7 +45,11 @@ std::string normalizeGlyphsURL(const std::string& url, const std::string& access
if (url.compare(0, mapbox.length(), mapbox) != 0)
return url;
return normalizeURL(url, "/v4/", accessToken);
const std::string fontstack = "mapbox://fontstack/";
if (url.compare(0, fontstack.length(), fontstack) == 0)
return normalizeURL(url, "/v4/", accessToken);
return normalizeURL(url, "/", accessToken);
}
std::string normalizeTileURL(const std::string& url, const std::string& sourceURL, SourceType sourceType) {

View File

@@ -15,6 +15,7 @@ TEST(Mapbox, SourceURL) {
TEST(Mapbox, GlyphsURL) {
EXPECT_EQ(mbgl::util::mapbox::normalizeGlyphsURL("mapbox://fontstack/{fontstack}/{range}.pbf", "key"), "https://api.tiles.mapbox.com/v4/fontstack/{fontstack}/{range}.pbf?access_token=key");
EXPECT_EQ(mbgl::util::mapbox::normalizeGlyphsURL("mapbox://fonts/v1/user/{fontstack}/{range}.pbf", "key"), "https://api.tiles.mapbox.com/fonts/v1/user/{fontstack}/{range}.pbf?access_token=key");
EXPECT_EQ(mbgl::util::mapbox::normalizeGlyphsURL("http://path", "key"), "http://path");
}