From 1ec90e34f54717a64272a9e7f16fd3c69fa04862 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Fri, 1 Aug 2025 20:38:54 -0700 Subject: [PATCH] refactor(js): simplify CSRF token retrieval from the document --- internal/ui/static/js/app.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/ui/static/js/app.js b/internal/ui/static/js/app.js index 63f6ca5f..4c8eb7c8 100644 --- a/internal/ui/static/js/app.js +++ b/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 || ""; } /**