Add fix_url

Sometimes, the parsed urls are invalid because of some whitespace add
the beginning/end of the url, or because of a missing uri sheme. The
fix_url function fixes this.