numeric tag entry point fix potential
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user