def isDeepLevelSubdomain(url: str) -> int: """ Return the no. of levels of subdomain of the given url e.g. abcbank.com.somedomain.com returns 2 """ domain = utils.getDomainFromUrl(url) return utils.getSubdomainFromDomain(domain).count('.') + 1
def test2leveldotcomdothk(self): self.assertEqual(utils.getSubdomainFromDomain('a.b.c.com.hk'), 'a.b')
def test1leveldotcom(self): self.assertEqual(utils.getSubdomainFromDomain('a.b.com'), 'a')