summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2023-03-14 13:25:09 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2023-03-14 13:25:09 +0800
commit4f0a8bdb67c1dea70e92465ff91bdefb6073dcdd (patch)
tree0f08634eafbb011dbbc33fbc153d62628f20bbeb
parent9cb11759ce9ce106c8bc4e43fdde54bfcdbf81cb (diff)
Safely rely on response URL now
-rw-r--r--interchange.cxx8
1 files changed, 5 insertions, 3 deletions
diff --git a/interchange.cxx b/interchange.cxx
index 06e5957..4f8d9e0 100644
--- a/interchange.cxx
+++ b/interchange.cxx
@@ -4,12 +4,14 @@
namespace QInterchange {
static Interchange* interchange;
- static QString currentPath;
+ static int sampleUrlLength;
Interchange::Interchange(const char* sampleURL, const char* image_Dir,
const QString& cookie, const QString& certificate)
{
interchange = this;
+ auto length = strlen(sampleURL);
+ sampleUrlLength = length + (sampleURL[length - 1] == '/');
interchange_init(sampleURL, image_Dir,
cookie.isEmpty() ? nullptr
: cookie.toLatin1().constData(),
@@ -24,10 +26,10 @@ namespace QInterchange {
void Interchange::page(QString const& path)
{
- currentPath = path;
interchange_page(path.toLatin1().constData(),
[](interchange_response* response) {
- interchange->emitPage(currentPath,
+ interchange->emitPage(QString{response->url}
+ .remove(0, sampleUrlLength + 1),
QString{response->data});
interchange_free_response(response);
});