webssh

Web based ssh client https://github.com/huashengdun/webssh webssh.huashengdun.org/
git clone http://git.hanabi.in/repos/webssh.git
Log | Files | Refs | README | LICENSE

commit 2e0f06e65086f461c20c9fbff89ce821191184f5
parent 28f45bd9a6a2caae6a356dd1f501a95d82062c81
Author: Sheng <webmaster0115@gmail.com>
Date:   Fri, 11 Jan 2019 15:02:30 +0800

Fixed is_same_primary_domain

Diffstat:
Mtests/test_utils.py | 4++++
Mwebssh/utils.py | 7+++++--
2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/tests/test_utils.py b/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)) diff --git a/webssh/utils.py b/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 == '.'