1
0
forked from w0bm/f0bm

numeric tag entry point fix potential

This commit is contained in:
x
2026-01-24 01:35:30 +01:00
parent 43da214f73
commit a9871187ab

View File

@@ -203,20 +203,22 @@ window.requestAnimFrame = (function () {
const navbar = document.querySelector("nav.navbar"); const navbar = document.querySelector("nav.navbar");
if (navbar) navbar.classList.add("pbwork"); if (navbar) navbar.classList.add("pbwork");
// Extract item ID from URL. Regex now handles query params, hashes, and trailing slashes. // Extract item ID from URL. Use the last numeric segment to avoid matching context IDs (like tag/1/...)
const match = url.match(/\/(\d+)(?:\/|#|\?|$)/); // Split path, filter numeric, pop last.
const pathSegments = new URL(url, window.location.origin).pathname.split('/');
const numericSegments = pathSegments.filter(s => /^\d+$/.test(s));
// Hide navbar pagination for Item View (matches SSR) // Hide navbar pagination for Item View (matches SSR)
const navPag = document.querySelector('.pagination-container-fluid'); const navPag = document.querySelector('.pagination-container-fluid');
if (navPag) navPag.style.display = 'none'; if (navPag) navPag.style.display = 'none';
if (!match) { if (numericSegments.length === 0) {
console.warn("loadItemAjax: No ID match found in URL", url); console.warn("loadItemAjax: No ID match found in URL", url);
// fallback for weird/external links // fallback for weird/external links
window.location.href = url; window.location.href = url;
return; return;
} }
const itemid = match[1]; const itemid = numericSegments.pop();
// <context-preservation> // <context-preservation>
// Extract context from Target URL first // Extract context from Target URL first