From a5998dc59b0b2ba37b4ff8543d5decb7e37c9cfa Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Fri, 6 Mar 2015 16:48:05 -0800 Subject: [PATCH] Fix conditional in normalizeSourceURL The existing conditional would always be false, since it was comparing a url that begins with "mapbox://". In fact no conditional is necessary; the secure TileJSON resource should always be requested. --- src/mbgl/util/mapbox.cpp | 3 +-- test/miscellaneous/mapbox.cpp | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/mbgl/util/mapbox.cpp b/src/mbgl/util/mapbox.cpp index f3fded0cd..5d9c630c1 100644 --- a/src/mbgl/util/mapbox.cpp +++ b/src/mbgl/util/mapbox.cpp @@ -26,8 +26,7 @@ std::string normalizeSourceURL(const std::string& url, const std::string& access // TileJSON requests need a secure flag appended to their URLs so // that the server knows to send SSL-ified resource references. - if (url.compare(0, 5, "https") == 0) - result += "&secure"; + result += "&secure"; return result; } diff --git a/test/miscellaneous/mapbox.cpp b/test/miscellaneous/mapbox.cpp index 9496f2d27..a9c709fe9 100644 --- a/test/miscellaneous/mapbox.cpp +++ b/test/miscellaneous/mapbox.cpp @@ -7,8 +7,8 @@ using namespace mbgl; TEST(Mapbox, SourceURL) { - EXPECT_EQ(mbgl::util::mapbox::normalizeSourceURL("mapbox://user.map", "key"), "https://api.tiles.mapbox.com/v4/user.map.json?access_token=key"); - EXPECT_EQ(mbgl::util::mapbox::normalizeSourceURL("mapbox://user.map", "token"), "https://api.tiles.mapbox.com/v4/user.map.json?access_token=token"); + EXPECT_EQ(mbgl::util::mapbox::normalizeSourceURL("mapbox://user.map", "key"), "https://api.tiles.mapbox.com/v4/user.map.json?access_token=key&secure"); + EXPECT_EQ(mbgl::util::mapbox::normalizeSourceURL("mapbox://user.map", "token"), "https://api.tiles.mapbox.com/v4/user.map.json?access_token=token&secure"); EXPECT_THROW(mbgl::util::mapbox::normalizeSourceURL("mapbox://user.map", ""), std::runtime_error); }