4
0
Эх сурвалжийг харах

refactor(js): simplify CSRF token retrieval from the document

Frédéric Guillot 11 сар өмнө
parent
commit
1ec90e34f5

+ 6 - 6
internal/ui/static/js/app.js

@@ -806,13 +806,13 @@ async function checkShareAPI(title, url) {
     window.location.reload();
 }
 
+/**
+ * Get the CSRF token from the HTML document.
+ *
+ * @returns {string} The CSRF token.
+ */
 function getCsrfToken() {
-    const element = document.querySelector("body[data-csrf-token]");
-    if (element !== null) {
-        return element.dataset.csrfToken;
-    }
-
-    return "";
+    return document.body.dataset.csrfToken || "";
 }
 
 /**