From 6631e1afa2cbae9838bcebd6835ee39503a21688 Mon Sep 17 00:00:00 2001 From: Luca Beltrame Date: Wed, 1 Mar 2017 16:10:01 +0100 Subject: [PATCH] Add scheme to thumbnailUrl if missing Konachan.com started offering preview URLs as // to accomodate for both HTTP and HTTPS: this however broke preview loading and also downloading. For now http is prepended to schemaless URLs. An addition would be to offer things via https and adjust the scheme depending on that. --- src/libdanbooru/danboorupost.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/libdanbooru/danboorupost.cpp b/src/libdanbooru/danboorupost.cpp index c4b97f4..57559d1 100644 --- a/src/libdanbooru/danboorupost.cpp +++ b/src/libdanbooru/danboorupost.cpp @@ -59,11 +59,31 @@ DanbooruPost::DanbooruPost(QVariantMap postData, QPixmap pixmap, m_width = postData.value(QStringLiteral("width")).toString().toInt(); m_url = postData.value(QStringLiteral("file_url")).toUrl(); + + if (m_url.scheme().isEmpty()) { + // Konachan.com offers // for both http and https, but this + // just creates schemaless URLs + m_url.setScheme("http"); + } + m_thumbnailUrl = postData.value(QStringLiteral("preview_url")).toUrl(); + + if(m_thumbnailUrl.scheme().isEmpty()) { + // Konachan.com offers // for both http and https, but this + // just creates schemaless URLs + m_thumbnailUrl.setScheme("http"); + } + m_size = postData.value(QStringLiteral("file_size")).toInt(); m_rating = RATING_MAP.value(postData.value(QStringLiteral("rating")).toString()); m_sampleUrl = postData.value(QStringLiteral("sample_url")).toUrl(); + if (m_sampleUrl.scheme().isEmpty()) { + // Konachan.com offers // for both http and https, but this + // just creates schemaless URLs + m_sampleUrl.setScheme("http"); + } + } DanbooruPost::DanbooruPost(QXmlStreamAttributes &postData, QPixmap pixmap, QObject *parent):