aboutsummaryrefslogtreecommitdiff
path: root/domain.py
blob: 0ec8ac77455e70cb61f555d4acac40d7a643f439 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env python3

def url_extract_domain(url):
    index = 0
    if url.startswith("http://"):
        index += 7
    elif url.startswith("https://"):
        index += 8

    if url.startswith("www.", index):
        index += 4

    end = url.find(".", index)
    if end == -1:
        return url[index:]
    else:
        return url[index:end]