From 4f0a8bdb67c1dea70e92465ff91bdefb6073dcdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Tue, 14 Mar 2023 13:25:09 +0800 Subject: Safely rely on response URL now --- interchange.cxx | 8 +++++--- 1 file 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); }); -- cgit v1.2.3