diff options
author | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2023-03-14 13:25:09 +0800 |
---|---|---|
committer | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2023-03-14 13:25:09 +0800 |
commit | 4f0a8bdb67c1dea70e92465ff91bdefb6073dcdd (patch) | |
tree | 0f08634eafbb011dbbc33fbc153d62628f20bbeb /interchange.cxx | |
parent | 9cb11759ce9ce106c8bc4e43fdde54bfcdbf81cb (diff) |
Safely rely on response URL now
Diffstat (limited to 'interchange.cxx')
-rw-r--r-- | interchange.cxx | 8 |
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); }); |