Adjust suggested_fn_from_title, add tests

This commit is contained in:
Iordanis Grigoriou 2017-07-08 16:28:58 +02:00
parent 82d194cf2e
commit c9fd182dba
2 changed files with 11 additions and 5 deletions

View File

@ -197,8 +197,8 @@ def suggested_fn_from_title(url_path, title=None):
_, ext = os.path.splitext(url_path)
if ext.lower() in ext_whitelist and title:
suggested_fn = utils.sanitize_filename(title)
if not suggested_fn.lower().endswith(ext.lower()):
suggested_fn += ext
if not suggested_fn.lower().endswith((".html", ".htm")):
suggested_fn += ".html"
else:
suggested_fn = None
return suggested_fn

View File

@ -39,16 +39,22 @@ def test_download_model(qapp, qtmodeltester, config_stub, cookiejar_and_cache):
'Installing qutebrowser _ qutebrowser.html'),
('http://qutebrowser.org/INSTALL.HTML',
'Installing qutebrowser | qutebrowser',
'Installing qutebrowser _ qutebrowser.HTML'),
'Installing qutebrowser _ qutebrowser.html'),
('http://qutebrowser.org/INSTALL.html',
'Installing qutebrowser | qutebrowser.HTML',
'Installing qutebrowser _ qutebrowser.HTML'),
('http://qutebrowser.org/',
'qutebrowser | qutebrowser',
'qutebrowser _ qutebrowser'),
'qutebrowser _ qutebrowser.html'),
('https://github.com/qutebrowser/qutebrowser/releases',
'Releases · qutebrowser/qutebrowser',
'Releases · qutebrowser_qutebrowser'),
'Releases · qutebrowser_qutebrowser.html'),
('http://qutebrowser.org/index.php',
'qutebrowser | qutebrowser',
'qutebrowser _ qutebrowser.html'),
('http://qutebrowser.org/index.php',
'qutebrowser | qutebrowser - index.php',
'qutebrowser _ qutebrowser - index.php.html'),
('https://qutebrowser.org/img/cheatsheet-big.png',
'cheatsheet-big.png (3342×2060)',
None),