Generate a new url based on the old one using URL

This commit is contained in:
Dan Sosedoff 2022-11-30 14:03:11 -06:00
parent dd1fb90355
commit 2a4434a04a
No known key found for this signature in database
GPG Key ID: 26186197D282B164

View File

@ -754,13 +754,29 @@ function runAnalyze() {
});
}
function exportURL(path, params) {
var url = new URL(window.location.href.split("#")[0]);
url.pathname += path;
for (key in params) {
url.searchParams.append(key, params[key]);
}
return url.toString();
}
function exportTo(format) {
var query = getEditorSelection();
if (query.length == 0) {
return;
}
var url = window.location.href.split("#")[0] + "api/query?format=" + format + "&query=" + encodeQuery(query) + "&_session_id=" + getSessionId();
var url = exportURL("api/query", {
"format": format,
"query": encodeQuery(query),
"_session_id": getSessionId()
})
var win = window.open(url, '_blank');
setCurrentTab("table_query");