diff options
author | kali <kali@leap.se> | 2013-01-31 05:26:18 +0900 |
---|---|---|
committer | kali <kali@leap.se> | 2013-01-31 05:30:28 +0900 |
commit | 555210630659018785fdb9d2318081a76b49fb4c (patch) | |
tree | df7a51aaa32d9436a86881f9815d66a0f28773a5 /src/leap/util/web.py | |
parent | 00276d12b44630315c19ff2cd0f906eac34d92cf (diff) |
actually merge the release/v0.2.0 branch!
My life has been a lie until this moment...
I had done:
git merge -s ours release/v0.2.0
to avoid deleting the debian folder...
but that left the src untouched...
Now I just rm'd the src folder and did a
git checkout release/v0.2.0 src/
... and merge happy! :)
Diffstat (limited to 'src/leap/util/web.py')
-rw-r--r-- | src/leap/util/web.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/leap/util/web.py b/src/leap/util/web.py new file mode 100644 index 00000000..15de0561 --- /dev/null +++ b/src/leap/util/web.py @@ -0,0 +1,40 @@ +""" +web related utilities +""" + + +class UsageError(Exception): + """ """ + + +def get_https_domain_and_port(full_domain): + """ + returns a tuple with domain and port + from a full_domain string that can + contain a colon + """ + full_domain = unicode(full_domain) + if full_domain is None: + return None, None + + https_sch = "https://" + http_sch = "http://" + + if full_domain.startswith(https_sch): + full_domain = full_domain.lstrip(https_sch) + elif full_domain.startswith(http_sch): + raise UsageError( + "cannot be called with a domain " + "that begins with 'http://'") + + domain_split = full_domain.split(':') + _len = len(domain_split) + if _len == 1: + domain, port = full_domain, 443 + elif _len == 2: + domain, port = domain_split + else: + raise UsageError( + "must be called with one only parameter" + "in the form domain[:port]") + return domain, port |