Skip to content

Commit

Permalink
Fix: exports get captured by captive nav and don't download (#601)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew-Dickinson authored Oct 6, 2024
1 parent e8ecd33 commit c08a668
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/meshweb/static/admin/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,19 @@ async function updateAdminContent(newUrl, options, updateHistory = true) {


function shouldNotIntercept(target) {
const url = new URL(target.href);
const isForm = target.tagName === "FORM";
let url = ""
if (isForm){
url = new URL(target.action);
} else {
url = new URL(target.href);
}

if (target.className === "capture-exclude") return true;
if (!url.pathname.startsWith("/admin/")) return true;
if (url.pathname.startsWith("/admin/login")) return true;
if (url.pathname.startsWith("/admin/logout")) return true;
if (url.pathname.endsWith("/export/") && isForm) return true;
if (url.host !== location.host) return true;

return false;
Expand Down Expand Up @@ -245,8 +252,11 @@ function interceptLinks() {

// Form submissions
window.addEventListener("submit", function (event) {
const form = event.target;
// Exit early if this navigation shouldn't be intercepted
if (shouldNotIntercept(form)) return;

async function handler() {
const form = event.target;
const formData = new FormData(form);
const method = form.method;

Expand Down

0 comments on commit c08a668

Please sign in to comment.