summaryrefslogtreecommitdiff
path: root/src/mbgl/storage
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 15:39:07 -0700
commit10f7af19ce1ec61f37459f9cd75e2a0c89a0c790 (patch)
tree28ddf8ce40a69f509a63bf2566a0bd622c35464f /src/mbgl/storage
parentcbff0a972a9e0a4210c94de1c36f0dce278d01e9 (diff)
downloadqtlocation-mapboxgl-10f7af19ce1ec61f37459f9cd75e2a0c89a0c790.tar.gz
[core] correctly alter sprite URLs when attaching sprite.png/sprite.json filenames
Diffstat (limited to 'src/mbgl/storage')
-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) {