##// END OF EJS Templates
urls: allow canonical_url to contain more than just a hostname...
Thomas De Schampheleire -
r7297:3d39e68f default
parent child Browse files
Show More
@@ -58,7 +58,7 b' def canonical_url(*args, **kargs):'
58 from kallithea import CONFIG
58 from kallithea import CONFIG
59 try:
59 try:
60 parts = CONFIG.get('canonical_url', '').split('://', 1)
60 parts = CONFIG.get('canonical_url', '').split('://', 1)
61 kargs['host'] = parts[1].split('/', 1)[0]
61 kargs['host'] = parts[1]
62 kargs['protocol'] = parts[0]
62 kargs['protocol'] = parts[0]
63 except IndexError:
63 except IndexError:
64 kargs['qualified'] = True
64 kargs['qualified'] = True
@@ -559,6 +559,8 b' class TestLibs(TestController):'
559 ('http://www.example.org', '/abc/xyz/', 'http://www.example.org/abc/xyz/'),
559 ('http://www.example.org', '/abc/xyz/', 'http://www.example.org/abc/xyz/'),
560 ('http://www.example.org', 'abc/xyz/', 'http://www.example.org/abc/xyz/'),
560 ('http://www.example.org', 'abc/xyz/', 'http://www.example.org/abc/xyz/'),
561 ('http://www.example.org', 'about', 'http://www.example.org/about-page'),
561 ('http://www.example.org', 'about', 'http://www.example.org/about-page'),
562 ('http://www.example.org/repos/', 'abc/xyz/', 'http://www.example.org/repos/abc/xyz/'),
563 ('http://www.example.org/kallithea/repos/', 'abc/xyz/', 'http://www.example.org/kallithea/repos/abc/xyz/'),
562 ])
564 ])
563 def test_canonical_url(self, canonical, test, expected):
565 def test_canonical_url(self, canonical, test, expected):
564 from kallithea.lib.helpers import canonical_url
566 from kallithea.lib.helpers import canonical_url
@@ -581,6 +583,8 b' class TestLibs(TestController):'
581
583
582 @parametrize('canonical,expected', [
584 @parametrize('canonical,expected', [
583 ('http://www.example.org', 'www.example.org'),
585 ('http://www.example.org', 'www.example.org'),
586 ('http://www.example.org/repos/', 'www.example.org'),
587 ('http://www.example.org/kallithea/repos/', 'www.example.org'),
584 ])
588 ])
585 def test_canonical_hostname(self, canonical, expected):
589 def test_canonical_hostname(self, canonical, expected):
586 from kallithea.lib.helpers import canonical_hostname
590 from kallithea.lib.helpers import canonical_hostname
General Comments 0
You need to be logged in to leave comments. Login now