summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2017-10-17 14:00:52 -0700
committerKonstantin Käfer <mail@kkaefer.com>2017-10-17 17:31:59 -0700
commit9c12a311f2ba2b26a44a6e13edd38bf8050e5d16 (patch)
tree688a1c9b77d5548be20bab85d97b0216b5cfb4e3 /src
parent0cd646180e787a59e600cb184b189a801e261c5c (diff)
downloadqtlocation-mapboxgl-9c12a311f2ba2b26a44a6e13edd38bf8050e5d16.tar.gz
[core] correctly alter sprite URLs when attaching sprite.png/sprite.json filenames
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/storage/resource.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/mbgl/storage/resource.cpp b/src/mbgl/storage/resource.cpp
index e75302b986..207dd2ee69 100644
--- a/src/mbgl/storage/resource.cpp
+++ b/src/mbgl/storage/resource.cpp
@@ -61,17 +61,19 @@ Resource Resource::image(const std::string& url) {
}
Resource Resource::spriteImage(const std::string& base, float pixelRatio) {
- return Resource {
- Resource::Kind::SpriteImage,
- base + (pixelRatio > 1 ? "@2x" : "") + ".png"
- };
+ util::URL url(base);
+ return Resource{ Resource::Kind::SpriteImage,
+ base.substr(0, url.path.first + url.path.second) +
+ (pixelRatio > 1 ? "@2x" : "") + ".png" +
+ base.substr(url.query.first, url.query.second) };
}
Resource Resource::spriteJSON(const std::string& base, float pixelRatio) {
- return Resource {
- Resource::Kind::SpriteJSON,
- base + (pixelRatio > 1 ? "@2x" : "") + ".json"
- };
+ util::URL url(base);
+ return Resource{ Resource::Kind::SpriteJSON,
+ base.substr(0, url.path.first + url.path.second) +
+ (pixelRatio > 1 ? "@2x" : "") + ".json" +
+ base.substr(url.query.first, url.query.second) };
}
Resource Resource::glyphs(const std::string& urlTemplate, const FontStack& fontStack, const std::pair<uint16_t, uint16_t>& glyphRange) {