Share URL-munging code

Still to do:

* Share more code
* Deal with this error:
    Uncaught Error: INVALID_STATE_ERR sockjs-0.3.4.js:1054
    SockJS._didClose sockjs-0.3.4.js:1054
    (anonymous function) sockjs-0.3.4.js:1330
    xo.onfinish sockjs-0.3.4.js:1412
    EventEmitter.emit sockjs-0.3.4.js:150
    that.xhr.onreadystatechange