From 8297cf0df93b9d9bb45da7276a2a26a844e028a2 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Tue, 20 Sep 2022 17:29:52 +0200 Subject: [PATCH] [xhr] Try to generate right uri for ajax call. --- src/ecmascript/spidermonkey/xhr.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/ecmascript/spidermonkey/xhr.cpp b/src/ecmascript/spidermonkey/xhr.cpp index efe3d748b..f0905ba98 100644 --- a/src/ecmascript/spidermonkey/xhr.cpp +++ b/src/ecmascript/spidermonkey/xhr.cpp @@ -368,7 +368,30 @@ xhr_send(JSContext *ctx, unsigned int argc, JS::Value *rval) } xhr->download.data = xhr; xhr->download.callback = (download_callback_T *)xhr_loading_callback; - struct uri *uri = get_uri(xhr->responseURL, URI_NONE); + + struct uri *uri = NULL; + + if (!strchr(xhr->responseURL, '/')) { + char *ref = get_uri_string(vs->uri, URI_DIR_LOCATION | URI_PATH); + + if (ref) { + char *slash = strrchr(ref, '/'); + + if (slash) { + *slash = '\0'; + } + char *url = straconcat(ref, "/", xhr->responseURL, NULL); + + if (url) { + uri = get_uri(url, URI_NONE); + mem_free(url); + } + mem_free(ref); + } + } + if (!uri) { + uri = get_uri(xhr->responseURL, URI_NONE); + } if (uri) { load_uri(uri, doc_view->session->referrer, &xhr->download, PRI_MAIN, CACHE_MODE_NORMAL, -1);