On Sat, 25 Jun 2011, Albrecht Mann wrote: > On Fri, 24 Jun 2011 13:42:11 -0700 > Don Armstrong <d...@debian.org> wrote: > > > On Fri, 24 Jun 2011, Joachim Breitner wrote: > > > as said previously somewhere, the # is something that the browser > > > handles internally to jump to a target, hence the server does not > > > see it (Unless it was URL-encoded for some reason, in which case it > > > becomes part of the URL). > > Ah yes, I see how I made a fool of myself there and assumed for a second > the anchor gets through to the server. I *should* know better than that. > > > Right, and we already properly handle # if it gets url encoded, which > > is why 'db #123456' works just fine. [Or > > http://bugs.debian.org/%23123456 ] > > But since I believe nobody actually does that (easier to simply strip > the #)
I actually do, which is why it works. > and something like "b.d.o/ #563030" doesn't get me there either, > this is probably wontfix or someone is willing to mess up > http://www.debian.org/Bugs/ with some JavaScript. Awesome. However, the regex for this is needlessly complicated [and because of that, it probably is incorrect.] var hashbug = function(url){ var bdo = '//bugs.debian.org/'; // regex sponsored by mootools -- matches: 1:'scheme', 2:'user', 3:'password', 4:'host', 5:'port', 6:'directory', 7:'file', 8:'query', 9:'anchor' var split_url = /^(?:(\w+):)?(?:\/\/(?:(?:([^:@\/]*):?([^:@\/]*))?@)?([^:\/?#]*)(?::(\d*))?)?(\.\.?$|(?:[^?#\/]*\/)*)([^?#]*)(?:\?([^#]*))?(?:#(.*))?/; This should really just be: var url_test = /^https?://.+\.debian.org/Bugs/\s*\#(\d+)\s*$/; and then var match = url_test.exec(url); if (url_test.test(url)) { location.href = bdo + match[1]; } return false; } hashbug(window.location.href); or similar. [Someone who actually writes JS can probably make the double testing slightly more elegant.] Don Armstrong -- Democracy means simply the bludgeoning of the people by the people for the people. -- Oscar Wilde http://www.donarmstrong.com http://rzlab.ucr.edu -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org