1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-12 02:52:20 -05:00

sickbeard.config.clean_url may add trailing /'s in unsuitable circumstances

Also adds some simple tests so we can avoid future regressions.
This commit is contained in:
Anthony Ryan 2015-01-13 08:44:33 -05:00
parent 8b84e4f4bc
commit 82da3171cd
2 changed files with 22 additions and 4 deletions

View File

@ -326,10 +326,8 @@ def clean_url(url):
scheme, netloc, path, query, fragment = urlparse.urlsplit(url, 'http') scheme, netloc, path, query, fragment = urlparse.urlsplit(url, 'http')
if not path.endswith('/'): if not path:
basename, ext = ek.ek(os.path.splitext, ek.ek(os.path.basename, path)) # @UnusedVariable path = path + '/'
if not ext:
path = path + '/'
cleaned_url = urlparse.urlunsplit((scheme, netloc, path, query, fragment)) cleaned_url = urlparse.urlunsplit((scheme, netloc, path, query, fragment))

20
tests/config_tests.py Normal file
View File

@ -0,0 +1,20 @@
import unittest
import sys
import os.path
sys.path.append(os.path.abspath('..'))
from sickbeard import config
class QualityTests(unittest.TestCase):
def test_clean_url(self):
self.assertEqual(config.clean_url("https://subdomain.domain.tld/endpoint"), "https://subdomain.domain.tld/endpoint")
self.assertEqual(config.clean_url("google.com/xml.rpc"), "http://google.com/xml.rpc")
self.assertEqual(config.clean_url("google.com"), "http://google.com/")
self.assertEqual(config.clean_url("http://www.example.com/folder/"), "http://www.example.com/folder/")
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(QualityTests)
unittest.TextTestRunner(verbosity=2).run(suite)