Fixed is_same_primary_domain

pull/58/head
Sheng 6 years ago
parent 28f45bd9a6
commit 2e0f06e650

@ -89,6 +89,10 @@ class TestUitls(unittest.TestCase):
domain2 = 'test'
self.assertFalse(is_same_primary_domain(domain1, domain2))
domain1 = 'com'
domain2 = 'example.com'
self.assertFalse(is_same_primary_domain(domain1, domain2))
domain1 = 'example.com'
domain2 = 'example.com'
self.assertTrue(is_same_primary_domain(domain1, domain2))

@ -103,9 +103,9 @@ def is_same_primary_domain(domain1, domain2):
dots = 0
l1 = len(domain1)
l2 = len(domain2)
m = 0 - min(l1, l2)
m = min(l1, l2)
while i >= m:
while i >= -m:
c1 = domain1[i]
c2 = domain2[i]
@ -122,5 +122,8 @@ def is_same_primary_domain(domain1, domain2):
if l1 == l2:
return True
if dots == 0:
return False
c = domain1[i] if l1 > m else domain2[i]
return c == '.'

Loading…
Cancel
Save