url.parse and friends are not a useful option, because js_dom does not give us valid window.location objects all of the time :(