2 Utilities to help handle urls
5 def normalize_url(url, scheme='http'):
7 Make sure there is a http at the head of what should be a url
9 >>> normalize_url("google.com")
11 >>> normalize_url("http://google.com")
13 >>> normalize_url("foo.com/a/b/c/d/e/f.html")
14 'http://foo.com/a/b/c/d/e/f.html'
15 >>> normalize_url("foo.com", "https")
17 >>> normalize_url(None)
19 # not much to do with None except avoid an exception
24 if url.find(scheme_sep) != -1:
27 return scheme + scheme_sep + url