From 7f86eb25bbd3f3b23e8344e1b593d7fd23182fa6 Mon Sep 17 00:00:00 2001 From: ECYaz Date: Thu, 30 Jul 2026 12:42:43 -0400 Subject: [PATCH 1/2] Keep relative links working after loading a category in place The category browser swaps the contribution list with AJAX and rewrites the address to the category's URL, which usually sits at a different directory depth. The board's own links are relative, so the browser re-resolves all of them against the new path: from a deeper category, Board index turns into customise/community/index.php on phpbb.com and the quick links, search and FAQ shift the same way. A direct load of the category regenerates the links at the right depth, which is why only the in-place navigation breaks. Resolve the document's relative links and form actions against the address it was rendered under before the first rewrite, so they keep pointing where they did when the page loaded. --- assets/javascript/ajax.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/assets/javascript/ajax.js b/assets/javascript/ajax.js index 9855381e5..81329449a 100644 --- a/assets/javascript/ajax.js +++ b/assets/javascript/ajax.js @@ -67,6 +67,17 @@ $contribList = $('.contrib-list-container'), $search = $('#category-search'); + // The address is about to change directory depth, which would make the + // browser re-resolve every relative URL on the page against the new + // path. Pin them to the URL the document was rendered against first. + $('a[href^="./"], form[action^="./"]').each(function() { + var name = (this.nodeName === 'FORM') ? 'action' : 'href', + resolver = document.createElement('a'); + + resolver.href = this.getAttribute(name); + this.setAttribute(name, resolver.href); + }); + phpbb.history.replaceUrl($this.attr('href')); var getParents = function($self) { From ab05507ae7209ca850e0ad51c99a606c428b5ebf Mon Sep 17 00:00:00 2001 From: Zi <113608189+ECYaz@users.noreply.github.com> Date: Mon, 3 Aug 2026 17:16:07 -0400 Subject: [PATCH 2/2] Pin every relative link, not only dot-slash ones Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- assets/javascript/ajax.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/assets/javascript/ajax.js b/assets/javascript/ajax.js index 81329449a..90e6f206f 100644 --- a/assets/javascript/ajax.js +++ b/assets/javascript/ajax.js @@ -70,11 +70,17 @@ // The address is about to change directory depth, which would make the // browser re-resolve every relative URL on the page against the new // path. Pin them to the URL the document was rendered against first. - $('a[href^="./"], form[action^="./"]').each(function() { + var resolver = document.createElement('a'); + $('a[href], form[action]').each(function() { var name = (this.nodeName === 'FORM') ? 'action' : 'href', - resolver = document.createElement('a'); + value = this.getAttribute(name); - resolver.href = this.getAttribute(name); + // Skip absolute URLs, protocol-relative URLs, root-relative URLs, and in-page anchors. + if (!value || value[0] === '#' || value[0] === '/' || value.indexOf('//') === 0 || /^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(value)) { + return; + } + + resolver.href = value; this.setAttribute(name, resolver.href); });