Browse Source

Fixed is_same_primary_domain

pull/58/head
Sheng 6 years ago
parent
commit
2e0f06e650
  1. 4
      tests/test_utils.py
  2. 7
      webssh/utils.py

4
tests/test_utils.py

@ -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))

7
webssh/utils.py

@ -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