Faking cleaner URLs in the Debian BTS

By Chris Lamb

UPDATE: You probably now want my Debbugs Enhancement Suite.

Debian bug #846500 requests that the Bug Tracking System moves the canonical URL for a given bug from:


… to the shorter, cleaner and generally less ugly:


(The latter currently redirects to the former.)

However, whilst we wait for a fix we can abuse the window.history object from the HTML History API to fake this locally:

var m = window.location.href
if (!m) return;

for (var x of document.getElementsByTagName("a")) {
  var href = x.getAttribute("href");
  if (href && href.match(/^[^:]+\.cgi/)) {
      // Mangle relative URIs; <base> tag does not DTRT
      x.setAttribute('href', "/cgi-bin/" + href);

history.replaceState({}, "", "/" + m[1] + window.location.hash);

This should work with most "user script" managers — I happen to use TamperMonkey in Chrome.

UPDATE: You probably now want my Debbugs Enhancement Suite.

Chris Lamb is a freelance software developer and the current Debian Project Leader. You can read other posts by me, see software I have written or read more about me. You can also follow me @lolamby.

Tags: GNU/Linux Hacks

Planets: ALUG UWCS WUGLUG Debian

Friday 3rd November 2017