generated from jric11/baseProject
This commit is contained in:
+9
-1
@@ -26,7 +26,15 @@ document.querySelectorAll('.club-action-modal').forEach(modal => {
|
||||
});
|
||||
const result = await response.json();
|
||||
if (!response.ok || !result.ok) throw new Error(result.error || 'Your change could not be saved.');
|
||||
window.location.assign(result.redirect);
|
||||
const target = new URL(result.redirect, window.location.href);
|
||||
if (target.origin !== window.location.origin) throw new Error('The return address could not be verified. Reload this page.');
|
||||
if (target.pathname === window.location.pathname && target.search === window.location.search) {
|
||||
// A fragment-only navigation would leave the saved dialog and stale content open.
|
||||
window.history.replaceState(null, '', target.href);
|
||||
window.location.reload();
|
||||
} else {
|
||||
window.location.assign(target.href);
|
||||
}
|
||||
} catch (failure) {
|
||||
error.textContent = failure instanceof SyntaxError || failure instanceof TypeError
|
||||
? 'Your change could not be confirmed. Reload the club page before retrying.'
|
||||
|
||||
Reference in New Issue
Block a user