handle `data` being passed to client library

Ended up being a fairly major rewrite, including using [URI.js](http://medialize.github.io/URI.js/) to handle URL parsing (which should be much more robust than my old regex).  Would love feedback.