From cf7adf17813fa01be259d0cfd08432c7c83186e7 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Tue, 31 Oct 2017 04:24:55 -0400 Subject: view-source: Handle "view-source:resources/*" paths --- (limited to 'src') diff --git a/src/view-source.c b/src/view-source.c index de555f8..45ce8e9 100644 --- a/src/view-source.c +++ b/src/view-source.c @@ -27,6 +27,7 @@ #include #include "application.h" +#include "resources.h" #include "string-utils.h" typedef struct { @@ -86,7 +87,8 @@ void mq_view_source_request(WebKitURISchemeRequest *request, MqApplication *application) { - gchar *path; + const gchar *path; + gchar *query_str; GHashTable *query; gint64 origin_tab_id; gchar *uri; @@ -96,15 +98,23 @@ mq_view_source_request(WebKitURISchemeRequest *request, gsize length; DataSignalData *data_signal_data; - path = g_strdup(webkit_uri_scheme_request_get_path(request)); - query = mq_parse_query_string(path); + path = webkit_uri_scheme_request_get_path(request); + + if (g_str_has_prefix(path, "resources/")) { + mq_resource_response(application, path + sizeof("resources"), + request); + return; + } + + query_str = g_strdup(path); + query = mq_parse_query_string(query_str); /* TODO: Handle missing tab ID ("origin-tab=0"). */ origin_tab_id = mq_atoi64(g_hash_table_lookup(query, "origin-tab")); uri = g_strdup(g_hash_table_lookup(query, "uri")); g_hash_table_unref(query); - g_free(path); + g_free(query_str); origin_tab = mq_application_get_tab(application, origin_tab_id); -- cgit v0.9.1