The seemingly defunct Poly9 released a rather awesome URLParser. Luckily I had a copy of the code in a project I did a while ago as it doesn’t appear to be available online anymore.
Thankfully Poly9 released the original code under the MIT license. So I have made a couple of minor adjustments and put it on Github. I have retained the original license terms as well.